0

I am using the workbench (https://workbench.developerforce.com/restExplorer.php) to create a request body example to post a feed element with a url link.

When using v29.0, the post address is: /services/data/v29.0/chatter/feeds/news/me/feed-items?text=New+status+post

and the request body is and this works:

{  
   "body":{  
      "messageSegments":[  
         {  
            "type":"Text",
            "text":"BEER!! "
         }
      ]
   },
   "attachment":{
        "attachmentType" : "Link",
        "url": "bbc.co.uk"
   }
}

But when I am using v39.0. I understand the post address is different which I am using: /services/data/v39.0/chatter/feed-elements?feedElementType=FeedItem&text=New+post

and use the new attributes Link Capability as suggested by the chatter api documentation I am getting the error:

JSON_PARSER_ERROR errorCode: JSON_PARSER_ERROR message: Unrecognized field "linkCapability" at [line:-1, column:-1]

Request body:

{ 
   "body" : {
      "messageSegments" : [
         {
            "type" : "Text",
            "text" : "When should we meet for release planning? "
         },
         {   
            "type" : "Mention",
            "id" : "005D00000016Qxp"
         }]
       },
   "subjectId" : "0050Y000001RUZp",
   "linkCapability": {
     "url": "http://www.example.com",
     "urlName": "Example"
   }
}

Does anyone have any suggestions please?

0

Leo, When making a rest call you can pass in values via the URL and the Request Body. The Request Body will override any conflicting settings on the URL. The query params you have in your POST URL are being ignored "?feedElementType=FeedItem&text=New+post" but that isn't why you aren't able to POST the feed item.

The reference to the link capability is incorrect. Capabilities are now referenced like this:

"capabilities":{
  "<capability name>" : {
      "<proper name>" : "<value>"
  }
}

If I were to re-write the example above it would be like this:

{ 
   "body" : {
      "messageSegments" : [
         {
            "type" : "Text",
            "text" : "When should we meet for release planning? "
         },
         {   
            "type" : "Mention",
            "id" : "005D00000016Qxp"
         }]
       },
   "subjectId" : "0050Y000001RUZp",
   "capabilities": { 
       "link": {
           "url": "http://www.example.com",
           "urlName": "Example"
   }
}

Doing a POST with this URL /services/data/v39.0/chatter/feed-elements and the above Request Body should work.

  • 1
    Thanks for the clear explanation Paul. Really appreciate this - I didn't see any documentation which showed me how like you have done. – leo Jul 6 '17 at 10:59

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.