We are trying to explore how we can post Jenkins build status to SFDC via Rest API Chatter. Tried below steps

  1. Generated Access Token

    curl -X POST --form client_id=3MVG94DzwlYDSHS4cCF4C29H72F9PRBtXYVT_Jr.lKdH0SfnDAyO6KV5_eTCuo58U4jJvY7BftllCZP5CRTuB --form grant_type=password --form client_secret=7446307574524850679 --form [email protected]  --form password=xxxxxSecurityToken https://cs4.salesforce.com/services/oauth2/token 

    Access_Token has generated successfully.

  2. To Post a comments on SFDC I used below command. But it is failing.

    curl -H "X-PrettyPrint: 1" -F 'json={"subjectId":"0F9P0000000Cwyf", "body":{ "messageSegments":[ { "type":"Text", "text":"Please accept this vidhya receipt." }, { "type" : "Mention", "id" : "0F9P0000000Cwyf"} ] }, "capabilities":{ "content":{ "description":"Receipt for expenses", "title":"Processed1.jpg" } } , "feedElementType":"FeedItem"}; type=application/json' -X POST https://cs4.salesforce.com/services/data/v37.0/chatter/feeds/record/0F9P0000000Cwyf/feed-elements -H 'Authorization: Bearer 00DP0000000DW8v!AQEAQFXjU_DkZXddrOVmcV3ZZ6x9zxOIzOeYL4gJK1.ysB6mIDtTNTamIocFsmQs5MKQOtceQsul_XCLPGM3.i8trJf2qnIF'
      % Total    % Received % Xferd  Average Speed   Time    Time     Time  Current
                                     Dload  Upload   Total   Spent    Left  Speed
    100   114    0   114    0     0     46      0 --:--:--  0:00:02 --:--:--    46

    [{"errorCode":"METHOD_NOT_ALLOWED","message":"HTTP Method 'POST' not allowed. Allowed are DELETE,GET,HEAD,PATCH"}]

1 Answer 1


Check the section Post a comment with a binary file in Chatter REST API Developer Guide.

To post a comment the syntax should look as below.

curl -H "X-PrettyPrint: 1" -F 'json={ "body":{ "messageSegments":[ { "type":"Text", "text":"Here's another receipt." } ] }, "capabilities":{ "content":{ "title":"receipt2" } } };
type=application/json' -F "[email protected];type=application/octet-stream" 
-X POST https://***instance_name***/services/data/v39.0/chatter/feed-elements/0D5RR0000004Grx/capabilities/comments/items 
-H 'Authorization: OAuth 00DRR0000000N0g!ARoAQB...' --insecure
  • Hi Saroj thanks for your response. I tried with your command but did not worked I got an error.bash: !AQEAQNiBb1LEAsIkTh2KhPMspdmj9r8JgYCSp85mZc_oDBaxcKRkwm_9_fjy1arOeniTWr2By0nAsvqP_rpGoXBpdvY81zS5': event not found Commented May 9, 2017 at 3:39

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .