I've been doing a lot of work with Livecode and APIs. Here's what I'd suggest doing.
Get the API calls working outside of Livecode in a tool designed to let you exercise the API calls. My tool of choice is Postman. Look it up on Google and have at it. There's a bit of a learning curve but once you figure out all the options (and there are lots), it's pretty easy to take a curl syntax and get it up and running in Postman. Postman can even generate code for you to make the call in some common languages (sadly not Livecode).
Using Postman guarantees that you figure out how the API is supposed to work before you introduce Livecode. Once you get a few curl API calls going in LC, you'll be amazed at how quickly you can wrap an entire API library up in LC function calls.
Now that you've got the calls working in Postman, move to LC (if you can't get the API working in Postman, DO NOT move to Livecode).
Make sure you set the headers to be what you had in Postman. Make sure you know whether the API call is a Post or a Get. For username/password, you can set the Authorization header as suggested, you may need to include the username/password in the url. If this is the case look up POST in the LC Dictionary to read about the nuances of this.
Code: Select all
post someData to URL "https://username:password@www.example.com/"
(make sure you always use https
I've used APIs where the authorization is included in a JSON or XML payload that is sent in the data of the request (this is dependent on the API definition). The API spec should tell you how to authorize your request.
Postman really is an invaluable tool to verify the parameters needed for the API call, then it's a matter of translating the syntax into LC.
Bob