onedrive - 无法订阅 onedrive API
问题描述
我尝试通过点击https://graph.microsoft.com/v1.0/subscriptions https://graph.microsoft.com/beta/subscriptions订阅 onedrive webhook
参数是:
"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 字符串;
- 标题中的“Content-Type”字段,值为“application/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)
推荐阅读
- vba - 如何解析主题行以生成然后启动 URL?
- java - SQLite的Spring boot2 JPA命名策略
- c++ - 如何从保存的几何图形中获取屏幕编号?
- sql - 怎么修?它表明一次性物品从未被丢弃
- sql - Oracle SQL - 检索分组到另一个值的值的最高出现次数
- microsoft-teams - 从 Teams 基于操作的消息扩展中获取消息附件?
- c# - 随着文件的增加,插入 FileTable 会变慢
- javascript - 您如何使用 javascript 自动将“/”添加到 mmyyyy 格式的日期?
- java - 如何正确加密用jackson编写的JSON文件
- android - 更改背景颜色也会影响文本颜色