MS Graph CalendarView BadRequest

Zeljko Zaric 1 Reputation point
2023-10-04T08:05:53.8133333+00:00

HI Together

Can somone tell me why am i getting bad request using this query in powershell script.Authentication with token is working fine and some other query are working with same authentication method.

Same query is working in graph explorer.

ErrorMessage : Invoke-RestMethod : The remote server returned an error: (400) Bad Request.

Thanks in advance for your help.

$query = "https://graph.microsoft.com/v1.0/resourceMb@company.com/calendarView?startDateTime=2023-10-03T00:00:00&endDateTime=2023-10-04T00:00:00"
$appointments = (Invoke-RestMethod -Headers @{Authorization = "Bearer $($AccessToken)"} -Uri $query -Method Get).Value

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
11,447 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Zeljko Zaric 1 Reputation point
    2023-10-04T13:10:29.38+00:00

    I found the soulution. users in https query was missing.

    "https://graph.microsoft.com/v1.0/users/resourceMb@company.com/calendarView?startDateTime=2023-10-03T00:00:00&endDateTime=2023-10-04T00:00:00"

    0 comments No comments