Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
menu search
person
Welcome To Ask or Share your Answers For Others

Categories

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. enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
437 views
Welcome To Ask or Share your Answers For Others

1 Answer

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:

enter image description here

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:

enter image description here


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
thumb_up_alt 0 like thumb_down_alt 0 dislike
Welcome to ShenZhenJia Knowledge Sharing Community for programmer and developer-Open, Learning and Share
...