Update records using Salesforce REST API - Patch method not working

10,269

Please check if you you're using the right implementation of PATCH method, see: Insert or Update (Upsert) a Record Using an External ID.

Also check if your REST URL is correct, probably your objectId is not passed in correctly from Javascript.

The ObjectName is the Name of an Salesforce table i.e. 'Contact'. And Id is the Id of a specific record you want to update in the table.

Similar:

Share:
10,269
user1399344
Author by

user1399344

Updated on July 16, 2022

Comments

  • user1399344
    user1399344 almost 2 years

    I'm trying to update a record residing in salesforce table. Im using the Java HttpClient REST API to do the same. Getting an error when we use PATCH to update a record in Salesforce.

    PostMethod post = new PostMethod(
        instanceUrl + "/services/data/v20.0/sobjects/" +
        objectName + "/" + Id + "?_HttpMethod=PATCH"
    );
    

    [{"message":"HTTP Method 'PATCH' not allowed. Allowed are HEAD,GET,POST","errorCode":"METHOD_NOT_ALLOWED"}]

    Also tried doing the following:

    PostMethod post = new PostMethod(
        instanceUrl + "/services/data/v20.0/sobjects/" + objectName + "/" + Id)
        {
            public String getName() { return "PATCH"; 
        }
    };
    

    This also returns the same error. We are using apache tomcat with commons-httpclient-3.1.jar library. Please advise on how this can be done.