Using the rest API, I want to be able to clear the value of a Picklist item. For example, I have the Account SObject which has an Industry Picklist. Using the Salesforce website, I can set the value of this to empty string by selecting the --None-- option. Using the REST API when attempting to set to nothing, the value is ignored:

{"Name":"Grand Hotels & Resorts", "Industry":""}

You can also see this behavior on the Salesforce workbench update page. Update an Account. Clear the Industry field and confirm the update. It is ignored.

  • 3
    Your JSON works in my org correctly. I suspect that you have a trigger or some logic turned on that's automatically cleaning your data. Try setting some debug logs in Setup > Logs > Debug Logs, and check the results after running an API call. – sfdcfox Jul 12 '16 at 22:55
  • 1
    Have you checked the "Strictly enforce picklist values" ... try to uncheck this and try your code – Amr Ibrahim Jul 13 '16 at 0:35

You will try to something like this:

Http h = new Http();
    HttpRequest req = new HttpRequest();
    string url = 'https://test1-for-dev-ed.my.salesforce.com/services/data/v20.0/sobjects/Account/0012800000iCVLi?_HttpMethod=PATCH';
    req.setHeader('Content-Type', 'application/json');
    req.setHeader('Authorization', 'Bearer '+userInfo.getSessionId());
    req.setBody('{"Industry" : ""}');
    HttpResponse res = h.send(req);

In debug log you will get


[10]|DEBUG|::::res:::System.HttpResponse[Status=No Content, StatusCode=204]

something like these, but the Account have to updated.

check your particular account record

| improve this answer | |

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.