Update records using Salesforce REST API - Patch method not working
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:
- Can I update without an ID?
- for Drupal: How to deal with SalesforceException: HTTP Method 'PATCH' not allowed. Allowed are HEAD,GET,POST
user1399344
Updated on July 16, 2022Comments
-
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.