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

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 -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) 

I was able to get this to work:

curl -X POST -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.