Page 1 of 1

cURL REST API to Livecode decyphering

Posted: Mon Oct 27, 2014 5:46 pm
by William Jamieson
I want to see if there is a known formula for creating cURL commands with Livecode based on the standard documentation of a REST API for Livecode.

So far I know this:
Livecode can POST, PUT, GET
POST can carry an object string of data along with it.

API syntax is usually something like
curl https://api.sandbox.paypal.com/v1/oauth2/token \
-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "<Client-Id>:<Secret>" \
-d "grant_type=client_credentials"
or
curl "https://my.ecwid.com/api/oauth/token" \
-XPOST \
-d client_id=abcd0123 \
-d client_secret=01234567890abcdefg \
-d code=987654321hgfdsa \
-d redirect_uri=https://www.example.com/myapp
-d grant_type=authorization_code
So what is one to do with the -u, -h, -d lines? I know that everything has to be withing 2 strings maximum. I have been searching through a lot of documentation and from the looks of it, other languages accept the format above and then automatically translate it into a proper cURL before transmitting. However Livecode does not.

So what would Livecode do???

-Will

Re: cURL REST API to Livecode decyphering

Posted: Tue Jan 27, 2015 5:23 am
by William Jamieson
Here is a help to the solution



Yeah, what worked for me is this format

-H "Accept: application/json" \
-H "Accept-Language: en_US" \
-u "<Client-Id>:<Secret>" \

##These are the headers which are in 1 single line

"https://my.ecwid.com/api/oauth/token" \

##Put this as the URL after the headers in the same line

-XPOST \
-d client_id=abcd0123 \
-d client_secret=01234567890abcdefg \
-d code=987654321hgfdsa \
-d redirect_uri=https://www.example.com/myapp
-d grant_type=authorization_code

##Put this into an array and convert to JSON ^

Summary:
Headers put one after another with spaces, the URL right after the headers separated by space and -d items put into an array and converted to JSON


Tinker around with that :)

-Will