[SalesForce] Custom field update API

I am working in a sandbox, and using the Tooling API. I need to update the metadata of the custom field in Salesforce, but I am unable to do so. For this I am trying to work on the PATCH method. Below is the postman request i have used to update the custom field metadata:

Method:

PATCH

URL:

https://cs21.salesforce.com/services/data/v34.0/tooling/sobjects/CustomField/customfieldid

HEADERS:

Authorization : Bearer TOken
Content-Type : application/json 

Body:

{

"FullName":"Contact.AFMO_Account__c",
"Metadata":
{
"description": "test"
}
}

Best Answer

The following worked for me as a PATCH via Workbench:

/services/data/v41.0/tooling/sobjects/CustomField/00N70000002kxvG

{
  "Metadata" : {
    "description" : "Test Number with Length 8 and 2 decimal places",
    "label" : "TestNumber",
    "type" : "Number",
    "precision" : 10,
    "scale" : 2
  },
  "FullName" : "Account.DFB__TestNumber__c"
}

I haven't gone through all the permutations, but if you take away fields such as precision you start getting errors such as:

[ {
"message" : "Must specify 'precision' for a CustomField of type Number",
"errorCode" : "FIELD_INTEGRITY_EXCEPTION",
"fields" : [ ]
} ]

Related Topic