Reputation: 145
I can't check StatusCode when REST API and parse JObject
code
string jsonResponse = HttpRequest(HostAPI, "POST", paramModel);
JObject jsonObject = JObject.Parse(jsonResponse);
if (jsonObject["data"] != null && jsonObject["StatusCode"]==200) ????
jsonResponse
{"data":[{"OBJID":1012540462,"SUPID":1041252952,"STATUSPTC":1.0,"DATEACTIVESUP":0.0}],"StatusCode":200}
I can not check StatusCode
if (jsonObject["StatusCode"]== 200)
{
//do something
}
Please help me if you know ???
Upvotes: 1
Views: 2277
Reputation: 538
jsonObject["StatusCode"] type is Newtonsoft.Json.Linq.JValue
So we have to explicitly cast it.
if ((int)jsonObject["StatusCode"] == 200)
{
Console.WriteLine("working");
}
You can find working sample here
Upvotes: 1