Good day all. I’m trying to form a simple Get Contents of URL request to retrieve data using an API described as the following in the developer documentation:
It is not clear to me what parameters I need to setup in the Headers section of the Get Contents of URL action. I thought it would be as simple as a single parameter “API_KEY” with value of my api key, but that is not working (see attached).
I’m out of my comfort zone and have struck out googling. Any guidance? Thanks — jay
The -u option sets the username and password for the request.
There are two authentication schemes: Basic and Digest.
Basic is the easier one and is probably used by your service (just a wild guess).
To send that data, you have to base64 encode the string {user}:{password}, where you replace each with the corresponding value, and then send it in the Authentication (edit: it’s Authorization) header with the value Basic {base64}.
So in your case you would encode API_KEY:{my API key} with base64 and then send it in the Authentication (edit: it’s Authorization) header like described above.
Thanks for the response. Very informative. I validated on the dev’s website that he is using “Basic”. I update the shortcut to the following and it is still not working. I’ll keep working on it… you’ve given me good guidance for further research.
Edit: I just validated the API and my API key by issuing direct curl command from Mac terminal. Worked as expected.
There might be 2 reasons since your API key is correct (I can think of):
you’ve included a space or line break at the and of your API key
your API key is longer than 49 characters and therefore the resulting base64 gets broken after 76 characters. You might try to set this to None in the base64 action.