【问题标题】:"UnknownError" creating a Booking through the Microsoft Graph Bookings API?\"UnknownError\" 通过 Microsoft Graph 预订 API 创建预订?
【发布时间】:2022-11-03 19:52:52
【问题描述】:

我正在尝试通过图形 API 在 Microsoft Bookings 中使用“Booking Business”端点,但documentation 不太清楚如何使其工作。我的身份验证正确,一切似乎都正常,但我似乎无法真正触发约会创建,而且我找不到任何方法来获得有关我的请求失败原因的更有意义的反馈。

我发送的核心请求如下所示:

POST https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/MyCalendar@MyOrg.com/appointments
Content-Type: application/json

{
    "@odata.type": "#microsoft.graph.bookingAppointment",
    "serviceId": "a98309e9-3104-411f-q681-71c7df95a178",
    "duration": "PT30M",
    "start_date_time":
    {
        "dateTime": "2022-12-22T14:30:00+00:00",
        "timeZone": "UTC"
    },
    "staffMemberIds":
    [
        "e220feb5-5bc-43c6-922z-a2cd5a545ec2"
    ],
    "isLocationOnline": true,
    "filedAttendeeCount": 1,
    "reminders@odata.type": "#Collection(microsoft.graph.bookingReminder)",
    "reminders":
    [
        {
            "message": "Remember your important appointment today",
            "offset": "PT120M",
            "recipients": "allAttendees"
        }
    ],
    "customers":
    [
        {
            "@odata.type": "#microsoft.graph.bookingCustomerInformation",
            "name": "Barrington Visitor",
            "emailAddress": "visitor@visitor-organisation.org"
        }
    ]
}

这会带来如下所示的响应:

{
 "error":{
   "code": "UnknownError",
   "message": "",
   "innerError":{
      "date": "2022-11-01T15:27:06",
      "request-id": "72e0b067-6347-4cb9-9257-04db4765908a",
      "client-request-id": "72e0e061-6347-4cb9-9127-0fdb47a590aa"
   }
  }
}

我在这里发现了两个已知的错误原因 - 如果一个不包括 customer 部分中的 @odata.type ,这将引发 InvalidModel 错误消息 changes: Cannot create an abstract class. 显然 on other endpoints 使用除 UTC 以外的时区导致引发相同的 UnknownError 消息,但我已将所有时区切换为 UTC,所以我希望避免特定原因。不过,显然有些问题仍然存在。

当我查看 AAD 门户中的请求 ID 时,它只显示成功的身份验证,没有提及随后引发的错误。

显然,这个请求比文档中的示例要小得多,所以我逐渐浏览并从对象中添加了越来越多的字段,甚至是那些似乎完全没有必要的字段。即使请求看起来像这样,我也会得到相同的响应:

{
    "@odata.type": "#microsoft.graph.bookingAppointment",
    "customerTimeZone": "UTC",
    "serviceId": "a98309e9-3104-411f-q681-71c7df95a178",
    "serviceName": "Appointment Service",
    "serviceNotes": "",
  "smsNotificationsEnabled": false,
    "serviceLocation":
    {
        "@odata.type": "#microsoft.graph.location",
        "address": null,
        "coordinates": null,
        "displayName": "Online meeting",
        "locationEmailAddress": null,
        "locationType@odata.type": "#microsoft.graph.locationType",
        "locationType": null,
        "locationUri": null,
        "uniqueId": null,
        "uniqueIdType@odata.type": "#microsoft.graph.locationUniqueIdType",
        "uniqueIdType": null
    },
    "startDateTime":
    {
        "@odata.type": "#microsoft.graph.dateTimeTimeZone",
        "dateTime": "2022-12-22T14:30:00+00:00",
        "timeZone": "UTC"
    },
    "endDateTime":
    {
        "@odata.type": "#microsoft.graph.dateTimeTimeZone",
        "dateTime": "2022-12-22T15:00:00+00:00",
        "timeZone": "UTC"
    },
      "duration": "PT30M",
    "postBuffer": "PT5M",
    "preBuffer": "PT1M",
  "price": 0,
  "priceType": "free",
   "priceType@odata.type": "#microsoft.graph.bookingPriceType",
    "staffMemberIds":
    [
        "e220feb5-5bc-43c6-922z-a2cd5a545ec2"
    ],
    "isLocationOnline": true,
    "maximumAttendeesCount": 1,
    "filledAttendeesCount": 1,
    "reminders@odata.type": "#Collection(microsoft.graph.bookingReminder)",
    "reminders":
    [
        {
            "@odata.type": "microsoft.graph.bookingReminder",
            "message": "Remember your important appointment today",
            "offset": "PT120M",
            "recipients@odata.type": "#microsoft.graph.bookingReminderRecipients",
            "recipients": "allAttendees"
        }
    ],
    "customers@odata.type": "#Collection(microsoft.graph.bookingCustomerInformation)",
    "customers":
    [
        {
            "@odata.type": "#microsoft.graph.bookingCustomerInformation",
            "name": "Barrington Visitor",
            "emailAddress": "visitor@visitor-organisation.org",
            "phone": null,
            "notes": null,
            "location": null,
            "timeZone": "UTC",
          "customQuestionAnswers": []
        }
    ]
}

这现在具有文档示例包含的所有属性,除了一些address 字段为空并且没有与客户关联的location,因为我必须制造一个。在这两种情况下,添加相关字段都不能解决问题。

有没有人找到解决甚至有用地解决此“UnknownError”消息的方法?或者,我的请求是否有问题而我错过了并且会避免它?

【问题讨论】:

    标签: microsoft-graph-api microsoft-graph-booking


    【解决方案1】:

    我不知道解决方案是什么,但我终于创建了一个约会 - 诀窍是直接通过 Microsoft 前端创建一个约会,然后转到 GET https://graph.microsoft.com/v1.0/solutions/bookingBusinesses/MyCalendar@MyOrg.com/appointments 获取创建的约会的副本。返回的 JSON 对象是服务所期望的,因此我能够将其用作成功调用的基础。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2019-03-20
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2022-11-04
      • 1970-01-01
      相关资源
      最近更新 更多