Sometimes you need to make a quick call against an api but may not have the willpower or time to crack open a script to get things done… When those moments hit just fall back on curl!
Send a json document to an API with basic authentication:
|
The -u
followed by the client_id:client_secret
is what will format the
request for basic authentication. If the response coming back is pretty long
and/or in json format you may want to check and see if you have json_pp
installed. If you are on Ubuntu this should be in there by default.
|
If you have an Oauth2 token and your curl supports it you can use
--oauth2-bearer
to set the header, this is a little different than the -u
header that is created for basic authentication.
|
Also, you if need to send post data the “normal” way you can leave off the
-H
header with content type and format your data with the
application/x-www-form-urlencoded
format:
|