+ Start a Discussion
MXGMXG 

Set createdDate for feed-elements via REST API

Hi Community,
I want to transfer notes to salesforce as Chatter Feeds.

I found this post https://developer.salesforce.com/docs/atlas.en-us.chatterapi.meta/chatterapi/connect_resources_feed_element.htm to create feed-elements via rest api, but I have to set the createdDate property of a record.

In the "setup" I set the 'Enable "Set Audit Fields upon Record Creation" and "Update Records with Inactive Owners" User Permissions' option and my API User Profile got the right to 'Set Audit Fields upon Record Creation'.

Can I set the createdDate via POST Request?
I hope someone can help me.
Purushotham YellankiPurushotham Yellanki
Hi MXG,

Based on this link here (https://help.salesforce.com/articleView?id=How-to-specify-the-values-in-Created-By-Created-Date-Last-Modified-By-ID-Last-Modified-Date&language=en_US&type=1) you should be able to specifiy values for CreatedDate and LastModifiedDate only on record create and not on update. You should be able to do this using POST request too, just give it a try and see




Thank you
MXGMXG
Maybe I forgot the main part of my question. :D

I tried it. I used the following POST Request:
 
{ 
   "body" : {
      "messageSegments" : [
         {
            "type" : "Text",
            "text" : "When should we meet for release planning? "
         }]
       },
   "createdDate": "2015-02-25",
   "feedElementType" : "FeedItem",
   "subjectId" : "0060Y00000BpXYZ"
}
But I get only an error:
 
[
    {
        "errorCode": "JSON_PARSER_ERROR",
        "message": "Unrecognized field \"createdDate\" at [line:-1, column:-1]"
    }
]
when I put the createdDate into the messageSegments I get this error:
 
[
    {
        "errorCode": "POST_BODY_PARSE_ERROR",
        "message": "Unsupported property for this version of Text message segment provided: createddate"
    }
]

I hope someone have a solution for my problem :)