Guilherme
Guilherme

Reputation: 1835

Response 400 on Microsoft Graph - Create calendar event: Property emailAddress in payload has a value that does not match schema

I'm creating a new calendar event through Microsoft Graph. I'm trying to insert organizer information on a Graph Calendar Event

if organizer.get('email'):
    log('email: ')
    log(organizer.get('email', ''))


eventJson["organizer"] = {
    "emailAddress": {
        "address":str(organizer.get('email', ''))
    }
}

log:

2019-05-17T17:05:45.421475+00:00 app[web.1]: ERROR
2019-05-17T17:05:45.421493+00:00 app[web.1]: <Response [400]>
2019-05-17T17:05:45.421501+00:00 app[web.1]: 
{
  "error": {
    "code": "BadRequest",
    "message": "Property emailAddress in payload has a value that does not match schema.",
    "innerError": {
      "request-id": "xxxxxxxxxxxx",
      "date": "2019-05-17T17:05:45"
    }
  }
}

I have already checked organizer.get('email') content. Also, in some other events, the same structure worked well. I don't know what the schema expects.

This is the example I have found on the documentation

"organizer": {
    "emailAddress": {
        "name": "Megan Bowen",
        "address": "[email protected]"
    }
}

Upvotes: 2

Views: 623

Answers (2)

Mikel
Mikel

Reputation: 391

You can't set the organizer in the POST body.

If you are using /me/calendars/{id}/events the user logged in is the organizer (me).

If you use /users/{id | userPrincipalName}/calendars/{id}/events you set the organizer with the {id | userPrincipalName} (for example with application permisions app)

Example: /users/[email protected]/calendars/{id}/events. Organizer:[email protected]

In the link you provided Graph docs for Create Event you have the request example (not response)

Upvotes: 2

Marc LaFleur
Marc LaFleur

Reputation: 33094

The organizer property is automatically set the owner of the calendar where the event was created. It isn't a property you can set. If you look at the examples, you'll see that organizer only shows up in the Response, not the Request.

Upvotes: 2

Related Questions