function readOnly(count){ }
Starting November 20, the site will be set to read-only. On December 4, 2023,
forum discussions will move to the Trailblazer Community.
+ Start a Discussion
Fenil Suthar 007Fenil Suthar 007 

ASP.net HTTP request with patch method

Example for creating Accountcurl
https://na1.salesforce.com/services/data/v20.0/sobjects/Account/customExtIdField__c/11999 -H "Authorization: Bearer token" -H "Content-Type: application/json" -d @newrecord.json -X PATCH
Example request body newrecord.json file
{ "Name" : "Express Logistics and Transport" }
My ASP.net code :
using (WebClient client = new WebClient()) 
{ 
client.Headers.Add("Authorization", "Bearer " + token.access_token); client.Headers.Add("Content-Type", "application/json"); NameValueCollection reqparm = new NameValueCollection(); reqparm.Add("Name", "This Is Test Data"); byte[] responsebytes = client.UploadValues(token.instance_url + "/services/data/v20.0/sobjects/Account/customExtIdField__c/11999", "PATCH", reqparm); string responsebody = Encoding.UTF8.GetString(responsebytes); 
}
Above code is not working. Getting Error (405) Method Not Allowed. I don't know how to use Patch Method.
Gaurav KheterpalGaurav Kheterpal
Where are you setting your request method to PATCH?

You should be doing something like
 
req.Method = "PATCH"
but I don't see this anywhere in your code snippet

If my answer helps resolve your query, please mark it as the 'Best Answer' & upvote it to benefit others and improve the overall quality of Discussion Forums.

Gaurav Kheterpal
Certified Force.com Developer| Salesforce Mobile Evangelist| Developer Forums Moderator| Dreamforce Speaker