I have an error with this cURL command:

curl https://myInstance.my.salesforce.com/services/data/v44.0/ -H "Authorization: Bearer 00D1l0000008e75!AQMAQJiLSTqCI5o..O5u3MJ9cDVg8hJJdIUe63mXGN.X..." -H "X-PrettyPrint:1"

It seems to be the "!" character in the Access_Token key who generates this error.

-bash: !AQMAQJiLSTqCI5o..O5u3MJ9cDVg8hJJdIUe63mXGN.X...": event not found

How can I fix it?


You need to wrap your authentication header in single quotes, rather than double quotes, to stop Bash from attempting to interpret its content:

curl https://myInstance.my.salesforce.com/services/data/v44.0/ -H 'Authorization: Bearer 00D1l0000008e75!AQMAQJiLSTqCI5o..O5u3MJ9cDVg8hJJdIUe63mXGN.X...' -H "X-PrettyPrint:1"

This would also apply if you had, for example, a $ in your parameter.

From TLDP:

Single quotes (' ') operate similarly to double quotes, but do not permit referencing variables, since the special meaning of $ is turned off. Within single quotes, every special character except ' gets interpreted literally.

Encapsulating "!" within double quotes gives an error when used from the command line. This is interpreted as a history command. Within a script, though, this problem does not occur, since the Bash history mechanism is disabled then.

  • Thank you very much. I just follow foolishly an SF example... I have learn another thing today.
    – YesPapa
    Nov 6 '18 at 14:29

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.