Forum Discussion
Martin Strasser
May 15, 2018Copper Contributor
Exchange Online REST API
Hello,
I want to use the REST-API from my Exchange Online account to edit the calendar entries.
When I try to connect with "invoke-webrequest" I get an error 403.
Where can I enable the API for my account in Exchange Online settings?
Regards,
Martin
REST is enabled by default. Are you providing an access token as part of the request? Do you have the necessary permissions to access the endpoint you are trying to (assuming you are using /user@domain.com/contacts)?
- Martin StrasserCopper Contributor
Hello,
I tried it with:
iwr "https://outlook.office.com/api/v2.0/me/calendarview?startDateTime=2018-05-01T01:00:00&endDateTime=2018-10-31T23:00:00" -Credential $(Get-Credential)
And the result is:
iwr : The remote server returned an error: (403) Forbidden.
At line:1 char:1
+ iwr "https://outlook.office.com/api/v2.0/me/calendarview?startDateTim ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-WebRequest], WebExc
eption
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeWebRequestCommandRegards,
Martin
You cannot pass credentials directly. You need to get a token and pass that token via an auth header. The documentation on that is here: https://docs.microsoft.com/en-us/outlook/rest/get-started