无法使用扩展数据创建事件 [英] Can't create an event with extended data

查看:80
本文介绍了无法使用扩展数据创建事件的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试使用Microsoft Graph API使用扩展数据创建日历事件.(实际上,由于无法过滤开放扩展的非id扩展值,因此我试图将现有的开放扩展转换为架构扩展)

在尝试之前,我已经成功创建了

解决方案

这是因为您的架构扩展名不是 extendedData .

当您使用 POST https://graph.microsoft.com/v1.0/schemaExtensions 创建事件类型的扩展名时,真实名称将被加上前缀.

赞:

并且基于此

I am trying to create a calendar event with extended data using Microsoft Graph API.(actually, I am trying to converting the existing open extension to schema extension since I couldn't filter the non-id extended value of the open extension.)

Before my try, I have already created my schema extension successfully and creating a calendar event with the schema extension responses an error code "BadRequest" and message "Requests must contain extension changes exclusively".

I tried to do this by following the doc.

POST https://graph.microsoft.com/v1.0/me/calendars/{calendar-group-id}/events

{
  "subject": "schema extension test",
  "body": {
    "contentType": "HTML",
    "content": "schema extension test"
  },
  "start": {
      "dateTime": "2021-01-22T12:00:00",
      "timeZone": "Eastern Standard Time"
  },
  "end": {
      "dateTime": "2021-01-23T14:00:00",
      "timeZone": "Eastern Standard Time"
  },
  "attendees": [],
  "extendedData": {
      "courseId": "11",
      "materialId": "22",
      "courseType": "video"
  }
}

response: 
{
    "error": {
        "code": "BadRequest",
        "message": "Requests must contain extension changes exclusively.",
        "innerError": {
            ...
        }
    }
}

Without extendedData, creating the event responses success, and after creating the event, if I patch the event with only extendedData, it responses an error "A type named 'Microsoft.OutlookServices.OpenTypeExtension' could not be resolved by the model. When a model is available, each type name must resolve to a valid type".

PATCH https://graph.microsoft.com/v1.0/me/calendars/{calendar-group-id}/events/{event-id}
    
    {
      "extendedData": {
          "courseId": "11",
          "materialId": "22",
          "courseType": "video"
      }
    }

response:
{
    "error": {
        "code": "RequestBodyRead",
        "message": "A type named 'Microsoft.OutlookServices.OpenTypeExtension' could not be resolved by the model. When a model is available, each type name must resolve to a valid type.",
        "innerError": {
            ...
        }
    }
}

I was able to succeed when I used Graph API explorer with signed in user by consent Calendars.Read permission.

But if I try the same thing in postman, it doesn't work.

I already have granted all calendar permissions including delegated and application permissions in Azure.

解决方案

This is because your schema extension name is not extendedData.

When you use POST https://graph.microsoft.com/v1.0/schemaExtensions to create an extension for Event type, the real name will be prefixed.

Like this:

And based on this known issue of Microsoft Graph:

You cannot specify a schema extension in the same operation as creating an instance of contact, event, message, or post. You must first create the resource instance and then do a PATCH to that instance to add a schema extension and custom data.

So we need to create the event first and then update it.

When updating the event, we need to specify the real extension name:

这篇关于无法使用扩展数据创建事件的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

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