1

I am currently developing an external application that uses the Salesforce REST API to consume.

The POST method to the endpoints /services/data/v47.0/sobjects/ContentNote&& /services/data/v47.0/sobjects/ContentDocumentLink work as expected and the Note I am creating shows up in Salesforce on the desired Account.

However, the CreatedById completely ignores the ID i have specified and just uses my name no matter what. I have enabled Set Audit Fields upon Record Creation in the permission sets for each user, or else it would be throwing a 400 Bad Request.

To start off, I don't even know how it is grabbing my name as the CreatedById, as I am using a seperate API account for the Username/Password authorization flow, and I even tested it by logging into a different account and creating it.

This is the payload for the /services/data/v47.0/sobjects/ContentNote endpoint.

$"{{\"Title\":\"{title}\", \"Content\":\"{messageEncoded}\", \"CreatedById\":\"{createdById}\", \"OwnerId\":\"{createdById}\"}}";

And this is the payload for the /services/data/v47.0/sobjects/ContentDocumentLink endpoint

$"{{\"ContentDocumentId\":\"{cnm.Id}\", \"LinkedEntityId\":\"{accountId}\", \"ShareType\":\"V\"}}";

Rest assured that the ID's are where they need to be, because it is clearly creating the note in my org. cnm.Id is the ID of the created note for the ContentNote endpoint.

Any ideas? Is this possible to do, or is this just another Salesforce quirk.

0

1 Answer 1

0

You might want to first check that the user you used in the CreatedById field, besides API account, also have permission to create record.

If that's already the case, you might want to try using this method instead:

{
     "CreatedById" : "<Record ID of user>"
}
//or you can use
{
     "CreatedBy": { "<Any Unique Field in User>" : "<value>"}
}

Please see "How to assign value to CreatedById fields via REST API in Salesforce" for detailed steps.

1
  • Welcome to Salesforce SE! While this may theoretically answer the question, it would be preferable to include the essential parts of the answer here, and provide the link for reference. Your blog includes key parts of the answer not shown here.
    – identigral
    Jun 21, 2021 at 15:09

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .