I am trying to read Rest Web API response. I am getting error while parsing the data
Response Content type : application/json; charset=utf-8
Response: {"access_token":"ot-a4943ac25cf94df3adacd11c71b8ea01","token_type":"Bearer","scope":["READ_USER_PROFILE","WRITE_CONVERSATIONS","READ_CONVERSATIONS"]}
DTO:
public class ResponseData
{
public string AccessToken { get; set; }
public string TokenType { get; set; }
public string Scope { get; set; }
}
public class Scope
{
public string[] RequestScope { get; set; }
}
Code:
using (HttpContent rescontent = response.Result.Content)
{
// ... Read the string.
Task<string> result = rescontent.ReadAsStringAsync();
// res = result.Result;
var responseData = JsonConvert.DeserializeObject<ResponseData>(result.Result);
Console.WriteLine("Response: {0}", responseData.AccessToken);
}
Error: Newtonsoft.Json.JsonReaderException: 'Unexpected character encountered while parsing value: [. Path 'scope', line 1, position 85.'
Programming Language : C#
Please let me know, how to correct this? I want to read the access token parameter from the response.