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
Angelina ShinAngelina Shin 

REST API - Inserting New Records Using Id as the External ID

Hi all, 

I've been attempting to implement the mentioed endpoint (https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_upsert.htm) .   According to the docs, this usage for this endpoint is for creating records when an external ID is not provided/available.   Therefore, the ID field becomes the external ID field.   When I create a simple post request to
https://yourInstance.salesforce.com/services/data/v37.0/sobjects/Account/Id
with the following request body (I used the docs example) 
{
    "Name" : "California Wheat Corporation",
    "Type" : "New Customer"
}
I receive the below error (where ACC_EXT__c is the external ID): 
[
    {
        "message": "Required fields are missing: [ACC_EXT__c]",
        "errorCode": "REQUIRED_FIELD_MISSING",
        "fields": [
            "ACC_EXT__c"
        ]
    }
]
I was under the assumption that the point of this endpoint was that it was meant to be called when there is no external.  Would you know why this is requiring an external ID?   Is there a problem with the API? 

Thanks in advance for your help! 


 
Best Answer chosen by Angelina Shin
Agustin BAgustin B
Hey Angelina, do you have the ACC_EXT__c as required in your field definition inside the object?
Maybe thats the reason. In that case remove the required field as you dont have it to insert it

If it helps please like and mark as correct if it solves your issue, it may help others.

All Answers

Agustin BAgustin B
Hey Angelina, do you have the ACC_EXT__c as required in your field definition inside the object?
Maybe thats the reason. In that case remove the required field as you dont have it to insert it

If it helps please like and mark as correct if it solves your issue, it may help others.
This was selected as the best answer
Angelina ShinAngelina Shin
Thank you Agustin, please can you advise how to remove the required field.   I tried to untick required, but this wasn't possible as it was grayed out.  
Angelina ShinAngelina Shin
Please ignore the last question.