You need to sign in to do that
Don't have an account?

Rest API - updating Record
Hi,
I am trying to update record. I tried both PATCH and POST as instructed in document but its not working.
when used Patch then I get "Invalid HTTP method: PATCH"
when I used POST then I get
"message" : "HTTP Method 'POST' not allowed. Allowed are HEAD,GET,PATCH,DELETE", "errorCode" : "METHOD_NOT_ALLOWED"
Can anyone help? Below the code
HttpRequest req = new HttpRequest(); req.setEndpoint('https://ap1.salesforce.com'+'/services/data/v26.0/sobjects/Contact/0039000000Jzxts'); req.setHeader('Authorization', 'OAuth ' + UserInfo.getSessionId()); req.setHeader('X-PrettyPrint', 'true'); req.setHeader('Content-Type','application/json'); req.setBody('{"FirstName":"Mktg"}'); req.setMethod('PATCH'); system.debug('URL---'+UserInfo.getSessionId()); Http http = new Http(); HTTPResponse res = http.send(req);
Somehow Salesforce is not allowing to do POST or PATCH within Salesforce. Later I used other Rest Client tool I was able to test it.