我试图通过点击订阅Onedrive webhooks https://graph.microsoft.com/v1.0/subscriptions https://graph.microsoft.com/beta/subscriptions
参数为:
"changeType": "created,updated,deleted",
"notificationUrl": url.
"resource": "me/drive/root",
"clientState": "client-specific string",
"expirationDateTime": "2018-01-01T11:23:00.000Z",
我收到如下错误:
{ error:
{ code: 'InvalidRequest',
message: 'Server could not process subscription creation payload.',
innerError:
{ 'request-id': 'id',
date: '2018-10-16T09:16:46' } } }
我正在当地尝试。
有什么解决方案吗?
确保发布 json 请求,这意味着:
- 请求正文是一个 json 字符串;
- 标头中的"内容类型"字段,值为"应用程序/json">
如果你使用Python,有一个快捷方式:
import requests
url = "https://graph.microsoft.com/beta/subscriptions"
headers = {'Authorization': 'Bearer ' + "YOUR_TOKEN"}
data = {
"changeType": "created,updated,deleted",
"notificationUrl": url.
"resource": "me/drive/root",
"clientState": "client-specific string",
"expirationDateTime": "2018-01-01T11:23:00.000Z"
}
resp = requests.post(headers=headers, json=data)
我在尝试使用邮递员的请求时遇到了同样的问题。尸体是x-www-form-urlencoded
格式。当我将正文格式更改为raw
并指定JSON
时,它起作用了。
不起作用的"x-www-form-urlencoded"格式
工作"原始"格式
看起来MS Graph API只接受某些输入格式。希望这会有所帮助!