I want to update Description field which appears under Custom Object Definition of a custom object via REST call. I referred Tooling and Metadata API documentation, but could not figure out a way do it. An example using curl will be helpful.
1 Answer
One option is to use the CustomObject.Description field.
Description
The object’s description. This can be useful to describe the reason for creating the object or its intended use.
If you know the Id of the custom object, then you can update the record using a PATCH call.
patchcustomobject.json
{
"Description" : "Updated via the REST API using curl"
}
curl command
curl https://na5.salesforce.com/services/data/v35.0/tooling/sobjects/CustomObject/01I70000000IDawEAG
-H "Authorization: Bearer token"
-H "Content-Type: application/json"
-d @patchcustomobject.json -X PATCH
Replace the token
with a valid session id (a.k.a. access token).
If you can't make a PATCH call you can do a POST instead by adding the following to the URL:
?_HttpMethod=PATCH
UPDATE
As noted by SSK in the comments, this produces the following error:
[
{
"message": "sObject type 'CustomEntityDefinition' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.",
"errorCode": "INVALID_TYPE",
"fields": []
}
]
The same error occurs with the equivalent call against the SOAP version of the Tooling API.
Looking at the documentation again, I note that the Description field doesn't have "Update" under the listed Properties. It would appear that the tooling API doesn't support changing this field. You may need to resort to the Metadata API.
-
1I have got the following error when I tried the above suggestion. Any idea what it means as I wasn't supplying name?[ { "message": "sObject type 'CustomEntityDefinition' is not supported. If you are attempting to use a custom object, be sure to append the '__c' after the entity name. Please reference your WSDL or the describe call for the appropriate names.", "errorCode": "INVALID_TYPE", "fields": [] } ]– SSKCommented Nov 11, 2015 at 0:11
-
@SSK Sorry about that, your right. It produces an error. It's either a bug in the API or it outright doesn't support updates in the Tooling API. I tried ManageableState as well as it was explicitly listed as supporting Update. That failed in the same way. You might need to go with the Metadata API instead. Commented Nov 11, 2015 at 0:37