web
You’re offline. This is a read only version of the page.
close
Skip to main content

Announcements

No record found.

News and Announcements icon
Community site session details

Community site session details

Session Id :
Customer experience | Sales, Customer Insights,...
Unanswered

WEB API: Update contact - The requested resource does not support http method 'PATCH'.

(2) ShareShare
ReportReport
Posted on by 2,664

Hi,

I try to use the web api to create a console app where I can update contacts.

I created a method to update contact:

UserDto userupd = new UserDto();
userupd.firstname = "Test11231";
userupd.lastname = "Test12112";
userupd.contactid = Guid.Parse("891330a0-274b-ec11-8c62-000d3ada7f0d");

string body = Newtonsoft.Json.JsonConvert.SerializeObject(userupd);
var userdetailAnswer = CrmRequest2(
new HttpMethod("PATCH"),
String.Format("{0}/{1}/contacts", "">xxxxxx.api.crm4.dynamics.com", "api/data/v9.2/"),
body)
.Result.Content.ReadAsStringAsync();

where CrmRequest2 is: 

public static async Task<HttpResponseMessage> CrmRequest2(HttpMethod httpMethod, string requestUri, string body = null)
{
// Acquiring Access Token
var accessToken = await AccessTokenGenerator();

var client = new HttpClient();
var message = new HttpRequestMessage(httpMethod, requestUri);

// OData related headers
message.Headers.Add("OData-MaxVersion", "4.0");
message.Headers.Add("OData-Version", "4.0");
message.Headers.Add("Prefer", "odata.include-annotations=\"*\"");
message.Headers.Add("Accept", "application/json");
// Passing AccessToken in Authentication header
message.Headers.Add("Authorization", $"Bearer {accessToken}");

// Adding body content in HTTP request
if (body != null)
message.Content = new StringContent(body, UnicodeEncoding.UTF8, "application/json");

HttpResponseMessage httpResponseResult =
client.SendAsync(message, HttpCompletionOption.ResponseContentRead).Result;

if (httpResponseResult != null)
{
IEnumerable<string> uri = null;
httpResponseResult.Headers.TryGetValues("OData-EntityId", out uri);
if (uri != null)
{
string entityId = uri.FirstOrDefault();
}
}

return await client.SendAsync(message);

}

When I execute the code, I have the error: 

The requested resource does not support http method 'PATCH'. 
Do you have any idea? 
thanks
Alessandro

Under review

Thank you for your reply! To ensure a great experience for everyone, your content is awaiting approval by our Community Managers. Please check back later.

Helpful resources

Quick Links

Season of Sharing Community Challenge Winners!

Congratulations to our community stars!

Women in Power Builds Momentum

Expanding mentorship, skilling, and AI innovation

Leaderboard > Customer experience | Sales, Customer Insights, CRM

#1
11manish Profile Picture

11manish 91 Super User 2026 Season 2

#2
Travis South Profile Picture

Travis South 71

#3
Daniyal Khaleel Profile Picture

Daniyal Khaleel 52 Most Valuable Professional

Last 30 days Overall leaderboard

Product updates

Dynamics 365 release plans