HttpClient does not have a patch out of the box. Just do something like this:
// more things here using (var client = new HttpClient()) { client.BaseAddress = hostUri; client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", base64Credentials); var method = "PATCH"; var httpVerb = new HttpMethod(method); var httpRequestMessage = new HttpRequestMessage(httpVerb, path) { Content = stringContent }; try { var response = await client.SendAsync(httpRequestMessage); if (!response.IsSuccessStatusCode) { var responseCode = response.StatusCode; var responseJson = await response.Content.ReadAsStringAsync(); throw new MyCustomException($"Unexpected http response {responseCode}: {responseJson}"); } } catch (Exception exception) { throw new MyCustomException($"Error patching {stringContent} in {path}", exception); } }
source share