Curl command no return - api

Im working with an api, in the documentaion found here:
http://api.simplicate.nl/
There is an example curl:
`curl -H “Authentication-Key: {API Key}” -H “Authentication-Secret:{API secret}” https://{subdomain}.simplicate.nl/api/v2/crm/organization.json`
I ran that code like this in terminal:
curl -H “Authentication-Key:XX” -H “Authentication-Secret:XX” https://mydomain.simplicate.nl/api/v2/crm/organization.json
It runs but returns nothing.

You are using Header inside “...” that is wrong. You have to use double quote "..." (not sure what it is called, standard double quote?).
So it should be:
curl -H "Authentication-Key:XX" -H "Authentication-Secret:XX" https://mydomain.simplicate.nl/api/v2/crm/organization.json
As a note, currently your curl is sending the headers as following with extra characters.
“Authentication-Key:XX”
“Authentication-Secret:XX”
But it should be:
Authentication-Key:XX
Authentication-Secret:XX

Related

Can I get a working curl command to remove a system from RHEL subscription?

I want to automate the addition and removal of VMs from the RHEL Subscription. I want to use a curl command if possible and keep it simple.
I tried executing curl commands on the api.access.redhat.com/management/v1/subscriptions endpoints but it is giving errors like "Authentication parameters missing".
Below is an example command I am using:
curl -X GET -s -k -u username:Password "https://api.access.redhat.com/management/v1/subscriptions" -H "accept: application/json"
Expected to see the list of Subscribed systems but getting the "Authentication parameters missing" message.
In order to get all the subscriptions you have, run the following command:
curl -H "Authorization: Bearer $access_token" "https://api.access.redhat.com/management/v1/subscriptions"
You can retrieve the access_token variable by running the following command:
curl https://sso.redhat.com/auth/realms/redhat-external/protocol/openid-connect/token -d grant_type=refresh_token -d client_id=rhsm-api -d refresh_token=$offline_token
The offline_token, instead, has to be generated from the API Tokens Page.
Check this article for further details.

Unable to call Azure Management Events REST API

I am trying to use the rest api found here: https://msdn.microsoft.com/en-us/library/azure/dn931934.aspx to get the azure events from my subscription. I have followed the instructions very carefully, but my GET requests return a 400 error:
{"Code":"BadRequest","Message":"The $filter query parameter value is invalid."}
My cURL request can be seen below. I've redacted any private info
curl -X GET -H "Authorization: bearer XXX" -H "content-type: application/json" "https://management.azure.com/subscriptions/YYY/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01&$filter=eventTimestamp%20ge%20%272016-07-25T22:00:37Z%27%20and%20eventTimestamp%20le%20%272016-07-25T23:36:37Z%27%20and%20eventChannels%20eq%20%27Admin,%20Operation%27"
I have tried many variations of the filter param, but I think this should be correct. Each space was replaced with a %20, and each ' was replaced with a %27.
If anyone can please inform me as to what the correct query should look like i'd really appreciate it!
Thanks!
Please try to change the double quotes over the url to the single quotes. And it works fine on my side after modification.
E.G.,
curl -X GET -H 'Authorization: bearer <token>' -H 'content-type: application/json' 'https://management.azure.com/subscriptions/XXX/providers/microsoft.insights/eventtypes/management/values?api-version=2014-04-01&$filter=eventTimestamp%20ge%20%272016-07-25T22:00:37Z%27%20and%20eventTimestamp%20le%20%272016-07-25T23:36:37Z%27%20and%20eventChannels%20eq%20%27Admin,%20Operation%27'

Wunderlist Api Update Reminder error

I want update reminder for task in Wunderlist.
Use Wunderlist Api:
curl -H "Content-Type: application/json" -H "X-Access-Token: xxx" -H "X-Client-ID: xxx" a.wunderlist.com/api/v1/reminders/12345 -X PATCH -d {"revision":1,"date":"2015-11-25T16:49:23"}
and response:
{"error":{"type":"not_found","translation_key":"api_error_not_found","message":"The
resource you requested could not be found."}}
For your curl request, the server is actually seeing this as parameter
{revision:1,date:2015-11-25T16:49:23}
But I think your valid json should be:
{"revision":1,"date":"2015-11-25T16:49:23"}
So the valid parameter from your curl should be as below with wrapped inside quote. I used double quote by assuming that you are doing from windows. If from unix, you can easily use single quote for the wrapping!
-d "{\"revision\":1,\"date\":\"2015-11-25T16:49:23\"}"

How to perform Basic Authorization using CURL and get a json/string response in terminal?

curl -X POST -u myusername:mypassword \
-H "Authorization: Basic YXBpdXNlcjphcGlwd2Q=" \
http://someapi.com/v1/auth/login
//Ignore slashes.
I'm using this command in terminal but not getting the desired result.
Desired result should be a json, I think something is wrong with my paramenters.

curl -h or curl --header not working

i'm trying to connect ti a web api service, box-api, and following the tutorial i have to type this command to fetch a folder in the user content:
curl https://api.box.com/2.0/folders/FOLDER_ID/items?limit=2&offset=0 -H "Authorization: Bearer ACCESS_TOKEN"
I tryied to connect from the command line to test the command but it keep complaining about the -H or the --header command saying that it doesn exist:
-bash: -H: command not found
-bash: --header: command not found
but when i type curl --help the command is in the manual:
-H, --header LINE Custom header to pass to server (H)
I'm confused, what should i do to connect to this site and get the JSON content? Thanks
Your url has & sign. and this is making end of command on there(and running at background). You can remove this error by using quotes around. Like this
curl "https://api.box.com/2.0/folders/FOLDER_ID/items?limit=2&offset=0" -H "Authorization: Bearer ACCESS_TOKEN"
Hope this helps.
There seem to be two problems:
The '&' in the middle of the URL passed to curl,
The order of the statements. The curl manual reports a different order for the statements. Example:
curl -H "Authorization: Bearer AUTH_KEY" "https://api.box.com/2.0/folders/0/items?limit=2&offset=0"
This should be the complete solution.