Page 1 of 1

[ASK] Pars JSON from API Link with Autentication and Password

Posted: Sat Mar 14, 2020 1:55 pm
by gilar
Hello everybody ....

I'm strugling to Pars JSON from a API link
here is the link https://api.racehero.io/v1/events/3134/ ... board.json
This is the API documentation https://racehero.docs.apiary.io/#/authe ... irst%2F200


and this is my code

Code: Select all

   -- add the HTTP headers
   put "Content-Type: application/json" & CRLF into tHeaders
   put "Accept: application/json" & CRLF after tHeaders
   set the httpHeaders to tHeaders
   
   -- encode the params
   put urlEncode("dc43bb5fab5f86a11fb9") into tUsername
   put urlEncode("gilarkadarsah") into tPassword
   
   --send to Parse and get the results
   put "https://api.racehero.io/v1/events/3134/live/leaderboard.json?Username="&tUsername&"&Password="&tPassword into loginURL
   put URL loginURL into tResults
   put tResults into field "Field"
   put tResults into tArrays
   
   ParsingJSon tArrays

anyone could point me into right direction?
Comment and Help would be Appriciate


Best Regards

Gilar

Re: [ASK] Pars JSON from API Link with Autentication and Password

Posted: Sat Mar 14, 2020 5:25 pm
by bangkok
gilar wrote:
Sat Mar 14, 2020 1:55 pm
I'm strugling to Pars JSON from a API link
What are the problems you face ?

Regarding your code, you might have a problem with :

Code: Select all

  ParsingJSon tArrays
You have 2 solutions :

Code: Select all

   put JsonImport(tResults) into tArray --- that's LiveCode JSON library
or

Code: Select all

put JsonToArray(tResults) into tArray  --- that MergJSON library
I prefer MergJSON library... more stable in my views.

Re: [ASK] Pars JSON from API Link with Autentication and Password

Posted: Sat Mar 14, 2020 5:56 pm
by gilar
My problem is login into API with Live code
how to put API key and Password in Livecode

I have done qith jaon

Re: [ASK] Pars JSON from API Link with Autentication and Password

Posted: Sat Apr 25, 2020 11:36 am
by gilar
Finally this solved with

Code: Select all

put "Authorization: Basic" && base64Encode("APIKEY:PASSWORD") into tHeader
   set the httpHeaders to tHeader
Hope it would be useful for somebody who has the same problem

Thanks