We are trying to explore how we can post Jenkins build status to SFDC via Rest API Chatter. Tried below steps
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.
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"}]