I am sending a PATCH request to an API in our system using Restsharp library. For the data under test, the API returns 400 response code with below response body
{
"display message" : "Validation Failed"
"Validation message": "id is required"
}
I have to validate response code and response contents. I see that the response code is received in httpresponseCode, I am not able to figure out how i can retrieve the response body contents
try{
RestClient client = SetUrl(endpoint);
var token = Readtoken();
RestRequest request = new RestRequest().AddStringBody(jsonData, DataFormat.Json).AddHeader("Authorization", "Bearer " + token);
return await client.PatchAsync(request);
}
catch (HttpRequestException ex)
{
var httpresponseCode = (int)ex.StatusCode;
log.InfoFormat("entered into http exception while sending patch");
}
Thanks in Advance