function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
james2000james2000 

how to create a status update with message segments using REST

I'm trying to create a user status update and I'm not having any success. I've not been able to find any examples of a chatter POST with a JSON request body. Are there any such examples (preferably a curl example)?

 

Here's what I'm trying 

curl -X POST https://na7.salesforce.com/services/data/v23.0/chatter/feeds/news/me/feed-items -H 'Authorization: OAuth ...' -H 'X-PrettyPrint:1' -H 'Content-Type: application/json; charset=UTF-8' -d "{\"body\":[\"text\":\"hola\", \"type\":\"Text\"]}" -v

 But I get the error:

"Can not deserialize instance of core.chatter.connect.resources.input.MessageBodyInputRepresentation out of START_ARRAY token at [line:1, column:2]",  "errorCode" : "JSON_PARSER_ERROR"

Best Answer chosen by Admin (Salesforce Developers) 
james2000james2000

I was able to get this to work:

curl -X POST https://na7.salesforce.com/services/data/v23.0/chatter/feeds/news/me/feed-items -H 'Authorization: OAuth ...' -H 'X-PrettyPrint:1' -H 'Content-Type: application/json; charset=UTF-8' -d "{\"body\":{\"messageSegments\":[{\"type\":\"Text\", \"text\":\"wtf\"}]}}" -v

 I had to wrap the request in an object with a "body" attribute which is not indicated in the REST docs as far as I can tell.