cURL REST API to Livecode decyphering

Got a LiveCode personal license? Are you a beginner, hobbyist or educator that's new to LiveCode? This forum is the place to go for help getting started. Welcome!

Moderators: FourthWorld, heatherlaine, Klaus, kevinmiller

Post Reply
William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

cURL REST API to Livecode decyphering

Post by William Jamieson » Mon Oct 27, 2014 5:46 pm

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

William Jamieson
VIP Livecode Opensource Backer
VIP Livecode Opensource Backer
Posts: 212
Joined: Fri Feb 01, 2013 1:31 am
Contact:

Re: cURL REST API to Livecode decyphering

Post by William Jamieson » Tue Jan 27, 2015 5:23 am

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

Post Reply