I'm trying to access specific fields of a json string returned when I authenticate to an API. When I attempt to print or manipulate the string I receive
System.NullReferenceException: 'Object reference not set to an instance of an object.'
var response = client.GetAsync(fullUri).Result;
string content = await response.Content.ReadAsStringAsync();
Console.WriteLine("StatusCode : " + (int)response.StatusCode + " " + response.StatusCode.ToString());
var jo = JObject.Parse(content);
var token = jo["Result"]["Token"].ToString(); //error mentioned above received here
Console.WriteLine(token.ToString()); //error mentioned above also recieved here
Console.WriteLine(content); //error mentioned above received here too
the string "content" holds the json looking like this:
{
"Result":{
"TenantId":"1",
"Token":"38255507",
"UserName":"kadmin",
"RoleId":2,
"ScopeId":"2",
"AdminId":16596942,
"MachineId":null,
"MachineGroupName":null,
"CultureInfo":"en-US",
"TimePref":"Browser",
"OffSetInMinutes":420,
"Attributes":null
},
"ResponseCode":0,
"Status":"OK",
"Error":"None"
}
I've tried applying many examples I've seen on stackoverflow but none seem to work