I am trying to update few fields on a system using httpClient. The code inside the method is:
HttpClient client = new HttpClient();
// building the uri
string url = "my url";
var uri = new Uri(url);
var uriWithCred = new UriBuilder(uri)
{
UserName = "UserName",
Password = "Password"
}.Uri;
// Prepare the payload, with the field to be updated
HttpContent payload = new StringContent("{\"incident_state\":\"8\"}", Encoding.UTF8, "application/json");
//Update request
var method = new HttpMethod("PATCH");
var request = new HttpRequestMessage(method, uriWithCred)
{
Content = payload
};
var response = await client.SendAsync(request);
if (response.IsSuccessStatusCode)
{
MessageBox.Show("success");
}
it is executing successfully, but somehow I don't get the success status code, and the target system is not updated. What could be wrong about this piece of code?
Thanks