Following a few solutions here, I chose to use NewtonSoft. But I'm unable to convert JSON to a class object. And I think, the json (or string) being passed to the method in not in the correct format.
class:
public class EmailAPIResult
{
public string Status { get; set; }
}
method:
//....code
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string result = streamReader.ReadToEnd();
//when hovered on "result", the value is "\"{\\\"Status\\\":\\\"Success\\\"}\""
//For Text Visualizer, the value is "{\"Status\":\"Success\"}"
//And for JSON Visualizer, the value is [JSON]:"{"Status":"Success"}"
EmailAPIResult earesult = JsonConvert.DeserializeObject<EmailAPIResult>(result);
//ERROR : Error converting value "{"Status":"Success"}" to type 'EmailAPIResult'.
}
The following code works:
using (var streamReader = new StreamReader(httpResponse.GetResponseStream()))
{
string good = "{\"Status\":\"Success\"}";
//when hovered on "good", the value is "{\"Status\":\"Success\"}"
//For Text Visualizer, the value is {"Status":"Success"}
//And for JSON Visualizer, the value is
// [JSON]
// Status:"Success"
EmailAPIResult earesult = JsonConvert.DeserializeObject<EmailAPIResult>(good); //successful
}
How should I format the "result", so that my code works.
httpResponseis empty