【发布时间】:2016-07-25 02:01:26
【问题描述】:
我从 Graph API 得到的错误响应如下。
{ “错误”: { "code": "ErrorItemNotFound", "message": "在商店中找不到指定的对象。", “内部错误”:{ “请求ID”:“c2b32b83-5ccf-4385-bee1-33afcc31deb0”, “日期”:“2016-07-25T00:25:16” } } }
当我尝试将响应反序列化为我自己的错误对象时,我得到一个错误
解析值时遇到意外字符:。路径'',行 0,位置 0。
复制上面的 JSON 并尝试使用此工具进行验证 https://jsonformatter.curiousconcept.com/
其他人有同样的问题吗?
更新
抱歉,各位回复晚了。下面是我正在使用的确切代码。我刚刚再次测试了这个,我得到了同样的错误。
端点 URL:https://graph.microsoft.com/v1.0/users/MY_USER@EMAIL/events/
// New rest client with the destination URL.
var client = new RestClient(url);
// Type of request
var request = new RestRequest(requestType);
// Headers
request.AddHeader("Authorization", "Bearer " + accessToken);
request.AddHeader("Content-Type", "application/json");
// Content serialized in a json format
if (requestType == Method.POST || requestType == Method.PATCH || requestType == Method.PUT)
{
var jsonBody = JsonConvert.SerializeObject(requestContent);
request.AddParameter("application/json", jsonBody, ParameterType.RequestBody);
}
var response = await client.ExecuteTaskAsync(request);
请求正文
{"Id":null,"Subject":"Maths","UserEmailAddress":"sample@sample.onmicrosoft.com","Start":{"DateTime":"2016-09-1T10:11:56","TimeZone":"Pacific/Auckland"},"End":{"DateTime":"2016-09-1T11:11:56","TimeZone":"Pacific/Auckland"},"Location":null,"Body":null,"ReminderMinutesBeforeStart":60,"IsReminderOn":true}
【问题讨论】:
-
您好 Thivy,感谢您试用 Microsoft Graph。您介意分享有关此问题的更多信息吗?您要访问哪个端点?你能和我们分享一下这个请求吗?
-
正如您已经完成的那样,提到的错误有效负载似乎是有效的 JSON。您是否使用客户端 SDK(如果是,是什么平台?)?如果没有,您使用什么库来反序列化 JSON 有效负载?
-
您能否提供一个反序列化代码示例? JSON 本身是有效的。
标签: office365 office365api microsoft-graph-api