I need to use Patch
method in my Web API. I tried like this:
using (var request = new HttpRequestMessage(new HttpMethod("Patch"), new Uri(url)))
{
var plainTextBytes = System.Text.Encoding.UTF8.GetBytes("log:pass");
string val = System.Convert.ToBase64String(plainTextBytes);
request.Headers.Add("Authorization", "Basic Auth "+val);
}
Because HttpMethod.Patch
works in .NET Core, but I still get a response of "wrong method".
I saw all posts about this, but I did not get answer for my question
I am using .NET FRAMEWORK and there is no HttpMethod.Patch
but in Postman i have responce 200 OK. Now i have an idea i have problem with sending body or the method.
I am defining method using:
request.Method = new HttpMethod("Patch");
But content i am defining using:
var jsonString = new StringContent(JsonConvert.SerializeObject(link), Encoding.UTF8,"application/json");
HttpContent content = jsonString;
request.Content = content;
var patch2Result = client.SendAsync(request);