I have this string which I need to deserialize.
"{\"errors\":{\"validationError\":[\"Custom error message here.\"]},\"title\":\"One or more validation errors occurred.\",\"status\":400}"
This is my code and I am using XUnit for my testing.
var response = await client.GetAsync("api/ABC/Check?draftId=" + draftId);
var responseString = await response.Content.ReadAsStringAsync();
var result = JsonConvert.DeserializeObject<VerificationResponseError>(responseString);
Assert.Equal("Custom error message here.", result.validationError[0]);
and this is my VerificationResponseError class.
public class VerificationResponseError {
public string errors { get; set; }
public List<string> validationError { get; set; }
}
But, it breaks at
var result = JsonConvert.DeserializeObject<VerificationResponseError>(responseString);