1

I never had this issue using the REST data API - I'm using the Chatter API and trying to post to a group. I am setting the correct instance url in the request, and passing the returned access token as a Bearer token in the Authorization request header - I receive a successful request when sending a GET request to (using cURL):

/services/data/v33.0/chatter/users/me 

but if I try to send a POST to:

/services/data/v33.0/chatter/feed-elements?feedElementType=FeedItem&subjectId=0F9Z00000000M9s&text=Test+post

The response is:

[1] 6054
[2] 6055
-bash: -H: command not found
[2]+  Done                    subjectId=0F9Z00000000M9s
[{"message":"Session expired or invalid","errorCode":"INVALID_SESSION_ID"}]

If I immediately issue the GET request (without reauthenticating or anything, just pasting and executing the request) after this, I receive a well-formed successful response again, so I can't make sense of receiving this error message. The integers being printed (e.g. 6054, 6055) increase each time I try to issue the POST request, if that helps at all.

Just to be sure, I've checked the group and nothing has been posted. Any thoughts or insights on this?

3

the shell is interpreting characters in the URL as shell commands, and not part of the URL, you need to quote the URL string in your curl call, e.g.

curl -X POST -H "Authorization: Bearer ..." "https://na1.salesforce...."

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.