我在dynamic jsonText = JsonConvert.DeserializeObject(json);
ERROR
解析值时遇到意外的字符:<。路径'',行 0,位置0。
CODE
string api = "https://api.linkedin.com/v1/people/~:(id,first-name,formatted-name,email-address)";
using (var webClient = new WebClient())
{
webClient.Headers.Add(HttpRequestHeader.Authorization, "Bearer " + token);
var json = webClient.DownloadString(api );
dynamic jsonText = JsonConvert.DeserializeObject(json);
}
答案 0 :(得分:2)
我认为有必要在json中指定你想要的结果,否则一些web服务会返回xml中的数据
webClient.Headers.Add(System.Net.HttpRequestHeader.Accept, "application/json");
//also the encoding if need
webClient.Headers.Add(System.Net.HttpRequestHeader.AcceptEncoding, "utf-8");
但在linkedin中你必须使用
webClient.Headers.Add("x-li-format", "json");
此处有更多信息