Reputation: 11
There's a few threads on this topic, but they haven't helped sadly. I'm using Curl, and a sample API call from: algorithmia - developers/getting-started/
Using the sample code provided I post this in Curl: curl -X POST -d '"MY_USERNAME"' -H 'Content-Type: application/json' -H 'Authorization: Simple MYKEY_SECRET' https://api.algorithmia.com/v1/algo/demo/Hello/0.1.1
I get this response:
curl: (6) Could not resolve host: application curl: (6) Could not resolve host: Simple curl: (6) Could not resolve host: simNBQHl {"error":{"message":"authorization required"}}
I've tried various edits (including double brackets, removing spacing at certain points) - this doesn't work, and at times gets an invalid json used response. Any insight into what obvious thing I may be missing?
I'm using Windows Command Prompt and pasting the text in after copying it from the website in case that may be a cause - although I've also tried pasting the code into notepad and then copying from there with no joy.
Thanks!
Upvotes: 1
Views: 8474
Reputation: 1840
The Windows Command Prompt doesn't treat ''
as an escaped string the way that UNIX prompts do, so it's reading application/json'
as a URL argument, and application
doesn't resolve as a DNS name (your first error) - see Escaping Double Quotes in Batch Script
You'd need to do something like:
curl -X POST -d """MY_USERNAME""" -H "Content-Type: application/json" -H "Authorization: Simple MYKEY_SECRET" "https://api.algorithmia.com/v1/algo/demo/Hello/0.1.1"
Upvotes: 4