-1

I have an authentication problem with a REST API Call with curl, I think its to do with the formatting of my curl input.

curl -v https://api.ananthsdomain.com/version1/testaccount/test \
     -H "Accept: text/xml \
         User-Agent: MyIn Interface \
         X-Api-Signature:  XXXXXXX+u:`date +%Y%m%d%H%M%S`:`echo XXXXXXX$(date +%Y%m%d%H%M%S)XXXXXXX | openssl dgst -binary -sha1 | openssl base64`"

I have to construct X-Api-Signature to match requirements from servers which includes API key, current date and sha1hash of the API key.

I'm receiving authentication error and I think it's because the signature is being set in the same line as User-Agent (output below)

Accept: text/xml
User-Agent: MyIn Interface           X-Api-Signature:  XXXXXXX+u:20160210112839:O9bXXXXXXXXXXXlVAXXXXXXXXXX=

The output I want to see is meant to be like this.

Accept: text/xml
User-Agent: MyIn Interface
X-Api-Signature: XXXXXXX+u:20160210112839:O9bXXXXXXXXXXXlVAXXXXXXXXXX=

How can I make curl produce the output so it appears like the above.

1

Take a look at the fine manual, which says for the -H/--header option: This option can be used multiple times to add/replace/remove multiple headers.

  • Just beat me to it! – GregL Feb 19 '16 at 14:27
2

Just to expand on @mschuett's answer, you should specify each header with it's own -H option, and curl will append the proper end-of-line marker.

Thus, your command would look like:

curl -v https://api.ananthsdomain.com/version1/testaccount/test  \
  -H "Accept: text/xml" \
  -H "User-Agent: MyIn Interface" \
  -H "X-Api-Signature:  XXXXXXX+u:`date +%Y%m%d%H%M%S`:`echo XXXXXXX$(date +%Y%m%d%H%M%S)XXXXXXX | openssl dgst -binary -sha1 | openssl base64`"

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.