为 MSGraph 的创建订阅 API 获取 400 错误请求错误 [错误代码 - ExtensionError] [英] Getting 400 Bad Request Error for MSGraph's create subscription api [Error Code - ExtensionError]

查看:100
本文介绍了为 MSGraph 的创建订阅 API 获取 400 错误请求错误 [错误代码 - ExtensionError]的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

尝试创建订阅以获取用于文件创建/上传的 msgraph one 驱动器通知的频道.我正在点击网址 -

Trying to create a subscription to get a channel for msgraph one drive notifications for file creation/upload. I am hitting the URL -

https://graph.microsoft.com/v1.0/subscriptions  

具有适当的标题和以下正文 -

with proper headers and the following body -

{ 
    "changeType": "updated",
    "notificationUrl": "https://xxxxx.xxxxxxxxx.com/zzzz/qwertqwert",
    "resource": "/users/{user-id}/drive/root",
    "expirationDateTime": "2017-02-18T19:49:40.000Z",
    "clientState": "justsomerandomstring"

}

我收到以下回复:400 错误请求错误

I am getting the following response : 400 Bad Request Error

{
  "error": {
    "code": "ExtensionError",
    "message": "Operation: Create; Exception: [Status Code: BadRequest; Reason: Bad Request]",
    "innerError": {
      "request-id": "2862896286-5415-4921-gbn5-8741288985",
      "date": "2017-02-17T17:30:22"
    }
  }
}

我在 30-32 小时前提出了同样的要求.在我的重定向 servlet 上获取订阅 ID 以及文件通知.无法弄清楚发生了什么变化.也找不到任何帮助文档

I was making the same request 30-32 hrs back. Was getting the subscription-id as well as the file notifications on my redirection servlet. Not able to figure out what changed. Couldn't find any helping documentation either

推荐答案

这里遇到了同样的错误,我花了一段时间才找出问题所在,所以我在这里与您分享.

Got the same error here and it took me a while to find out what is the problem so I share this with you here.

这是工作代码:

$subscription = new Subscription([
  'resource'        => "me/mailFolders('Inbox')/messages?filter=id eq %27" . $draftEmail->getId() . '%27', 
  'notificationUrl' => 'https://my.domain.fr',
  'changeType'      => 'updated',
  'expirationDateTime' => date(DATE_ISO8601, strtotime('+48 hours'))
]);

对我来说错误的那一行是:

The line which was wrong for me is:

'resource' => 'me/messages/' . $draftEmail->getParentFolderId(),

我用

'resource' => "me/mailFolders('Inbox')/messages?filter=id eq %27" . $draftEmail->getId() . '%27', 

我在此链接中找到了答案:https://msdn.microsoft.com/en-us/office/office365/api/notify-rest-operations#subscribe-to-changes-in-my-mail-calendar-contacts-or-tasks

I found my answer in this link: https://msdn.microsoft.com/en-us/office/office365/api/notify-rest-operations#subscribe-to-changes-in-my-mail-calendar-contacts-or-tasks

但在我看来,资源"参数应该更多地记录在图形 API 文档中,并且错误消息返回必须说明为什么这是一个错误请求.

But in my opinion the "resource" parameter should be more documented on graph api documentation and the error message return must specify WHY this is a BadRequest.

这篇关于为 MSGraph 的创建订阅 API 获取 400 错误请求错误 [错误代码 - ExtensionError]的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆