You need to sign in to do that
Don't have an account?
Denise Crosby
rest api update error "the id field should not be specified in the sobject data"
I am trying to update a custom object using REST api like this:
REST method:
POST
URI endpoint:
/services/data/v41.0/sobjects/estimator__c
Request header:
Content-Type: application/json; charset=UTF-8
Accept: application/json
Request body:
{
"id" : "a014100000OsY9iAAF",
"active__c" : "false"
}
I get error
INVALID_FIELD
REST method:
POST
URI endpoint:
/services/data/v41.0/sobjects/estimator__c
Request header:
Content-Type: application/json; charset=UTF-8
Accept: application/json
Request body:
{
"id" : "a014100000OsY9iAAF",
"active__c" : "false"
}
I get error
INVALID_FIELD
- message: The Id field should not be specified in the sobject data.
- errorCode: INVALID_FIELD
What apex code are you using? or are you just using the workbench?
REST method:
PATCH
URI endpoint:
/services/data/v41.0/sobjects/estimator__c/a014100000OsY9iAAF
Request header:
Content-Type: application/json; charset=UTF-8
Accept: application/json
Request body:
{
"active__c" : "false"
}
For an update, use: "PATCH" instead of "POST" with the workbench.
You can read this great Aakanksha Singh's post for complete examples: For editing/updating records through REST API we use the /sobjects/ URI. Please make sure HTTP method is set to PATCH: https://webkul.com/blog/how-to-run-rest-api-through-workbench-salesforce/
https://trailhead.salesforce.com/en/modules/api_basics/units/api_basics_rest
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_update_fields.htm
All the best
Alain
All Answers
What apex code are you using? or are you just using the workbench?
REST method:
PATCH
URI endpoint:
/services/data/v41.0/sobjects/estimator__c/a014100000OsY9iAAF
Request header:
Content-Type: application/json; charset=UTF-8
Accept: application/json
Request body:
{
"active__c" : "false"
}
For an update, use: "PATCH" instead of "POST" with the workbench.
You can read this great Aakanksha Singh's post for complete examples: For editing/updating records through REST API we use the /sobjects/ URI. Please make sure HTTP method is set to PATCH: https://webkul.com/blog/how-to-run-rest-api-through-workbench-salesforce/
https://trailhead.salesforce.com/en/modules/api_basics/units/api_basics_rest
https://developer.salesforce.com/docs/atlas.en-us.api_rest.meta/api_rest/dome_update_fields.htm
All the best
Alain
1) By the way, for boolean values, it is just "active__c" : false (without double-quotation marks). you already type the corrected value yourself for sure as needed and I made my tests without double-quotation marks with a checkbox field (but at the end, I copy/paste your value as active__c could be a string for you).
2) Add Lookup Field Lightning Component: Marcus Torres and Greg Rewis communicated about this very expected component on the idea below.
<lightning:inputField> with a lookup field in Spring '18.
Marcus Torres and Greg Rewis are both known in France because they gave lectures on Lightning components during the European Lightning Now Tours in 2016 and 2017.
https://success.salesforce.com/ideaView?id=08730000000Dom1AAC