我正在尝试使用REST API将简单的文本文件上传到OneDrive。
我在portal.azure.com上创建了应用程序,并添加了以下API权限:
![图片描述](https://istack.dev59.com/mkIkS.webp)
我创建了一个令牌:
https://login.microsoftonline.com/<我的租户名称>/oauth2/v2.0/token
发送以下参数:
- grant_type client_credentials
- client_id 我的客户端ID
- client_secret 我的客户端密码
- scope https://graph.microsoft.com/.default
Content-Type为application/x-www-form-urlencoded,Keep-Alive为true。
我将其作为POST请求发送,并获得带有令牌的JSON。
然后我尝试将文本作为文件上传:
使用以下URL:
https://graph.microsoft.com/v1.0/drive/root://test.txt:/contentauthorization Bearer {我的令牌字符串}
Content-Type为text/plain
Body为"The string that needs to upload"
{ "error": { "code": "BadRequest", "message": "Unable to retrieve tenant service info.", "innerError": { "request-id": "098f37d5-96fd-44d0-905b-c147eac223f5", "date": "2020-05-19T11:43:03" } } }
![图片描述](https://istack.dev59.com/3P7oi.webp)
我做错了什么?
谢谢您的帮助。