Search code examples
soapexchange-serverexchangewebservicesaccess-rights

Update event does not work with EWS Access Denied


I am creating Meeting from application using EWS. With soap request

{  
   "body":{  
      "m:CreateItem":{  
         "attributes":[  
            {  
               "SendMeetingInvitations":"SendToAllAndSaveCopy"
            }
         ],
         "m:Items":[  
            {  
               "t:CalendarItem":{  
                  "t:Subject":"Booked from application",
                  "t:Body":{  
                     "attributes":[  
                        {  
                           "BodyType":"Text"
                        }
                     ],
                     "value":"Meeting body"
                  },
                  "t:Start":"2016-03-02T13:11:59+00:00",
                  "t:End":"2016-03-02T13:45:00+00:00",
                  "t:Location":"room1",
                  "t:RequiredAttendees":[  
                     {  
                        "t:Attendee":{  
                           "t:Mailbox":{  
                              "t:EmailAddress":"[email protected]"
                           }
                        }
                     }
                  ]
               }
            }
         ]
      }
   },
   "headers":{  
      "Authorization":"Basic somestringsdafsdfsdfsdfsdfsf"
   },
   "additionalNamespaces":[  
      "xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\"",
      "xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\""
   ],
   "soapHeader":{  
      "t:ExchangeImpersonation":{  
         "t:ConnectingSID":{  
            "t:PrincipalName":"[email protected]"
         }
      }
   },
   "method":"POST",
   "url":"https://outlook.office365.com/EWS/Exchange.asmx"
}

I am also trying to edit the meetings duration via application and it works fine also. With SOAP request:

{  
   "body":{  
      "m:UpdateItem":{  
         "attributes":[  
            {  
               "SendMeetingInvitationsOrCancellations":"SendToAllAndSaveCopy"
            },
            {  
               "MessageDisposition":"SaveOnly"
            },
            {  
               "ConflictResolution":"AlwaysOverwrite"
            }
         ],
         "m:ItemChanges":{  
            "t:ItemChange":{  
               "t:ItemId":{  
                  "attributes":[  
                     {  
                        "Id":"AAApAHJvb20xQGNlcnR1c2ludGVybmF0aW9uYWwub25taWNyb3NvZnQuY29tAEYAAAAAAMWslF/s3JlHvuBz+Grw4nkHAMq37IYLqfhKh5oHo2fodacAAAAAAQ0AAMq37IYLqfhKh5oHo2fodacAAFweeHQAAA=="
                     },
                     {  
                        "ChangeKey":"DwAAABYAAADKt+yGC6n4SoeaB6Nn6HWnAABcIvBS"
                     }
                  ]
               },
               "t:Updates":{  
                  "t:SetItemField":{  
                     "t:FieldURI":{  
                        "attributes":[  
                           {  
                              "FieldURI":"calendar:End"
                           }
                        ]
                     },
                     "t:CalendarItem":{  
                        "t:End":"2016-03-02T15:00:00+00:00"
                     }
                  }
               }
            }
         }
      }
   },
   "headers":{  
      "Authorization":"Basic somestringssdasasfasfasfasfaf"
   },
   "additionalNamespaces":[  
      "xmlns:m=\"http://schemas.microsoft.com/exchange/services/2006/messages\"",
      "xmlns:t=\"http://schemas.microsoft.com/exchange/services/2006/types\""
   ],
   "soapHeader":{  
      "t:ExchangeImpersonation":{  
         "t:ConnectingSID":{  
            "t:PrincipalName":"[email protected]"
         }
      }
   },
   "method":"POST",
   "url":"https://outlook.office365.com/EWS/Exchange.asmx"
}

Where problems starts is, when I create meeting from outlook.office.com using Exchange web interface. I get error with message:

Access is denied. Check credentials and try again., Cannot get ID from name.

The SOAP request is the same except change keys. I have read on some similar problems that it might be due to the rights on calendar. I am not quite clear with that.

Could you please advise on this problem.

EDIT:

{  
   "t:ExchangeImpersonation":{  
      "t:ConnectingSID":{  
         "t:PrimarySmtpAddress":"[email protected]"
      }
   }
}

Solution

  • It maybe your impersonation header is test007 the Mailbox your trying to access or just the service account your using ?

    I'd suggest you use the PrimarySMTPAddress to ensure you are specifying the Mailbox to access rather then a user eg

          "t:ExchangeImpersonation":{  
         "t:ConnectingSID":{  
            "t:PrimarySmtpAddress":"[email protected]"
         }
    

    Also when you say

    Where problems starts is, when I create meeting from outlook.office.com using Exchange web interface. I get error with message

    Do you mean you get the error in the Outlook Web App or in your code ?

    Cheers Glen