I am trying to create a Patch
request with theHttpClient
in dotnet core. I have found the other methods,
using (var client = new HttpClient())
{
client.GetAsync("/posts");
client.PostAsync("/posts", ...);
client.PutAsync("/posts", ...);
client.DeleteAsync("/posts");
}
but can't seem to find the Patch
option. Is it possible to do a Patch
request with the HttpClient
? If so, can someone show me an example how to do it?
Thanks to Daniel A. White's comment, I got the following working.
using (var client = new HttpClient())
{
var request = new HttpRequestMessage(new HttpMethod("PATCH"), "your-api-endpoint");
try
{
response = await client.SendAsync(request);
}
catch (HttpRequestException ex)
{
// Failed
}
}