graph api url calling work in the explorer but doesnt with python script calls Error: 404,

Brosk 0 Reputation points
2023-11-23T16:25:31.23+00:00

i am using microsoft graph explorer to call this url :
https://graph.microsoft.com/v1.0/users/demo-kira@outlook.com/messages
which return all the messages and everything is fine.
but when I use the URL call in my Python script i get :
Error: 404, Details: {"error":{"code":"ErrorInvalidUser","message":"The requested user 'demo-kira@outlook.com' is invalid."}}

this is a personal email btw
I tried the api on my work email everything was fine but now that I created this account something gone wrong.
I changed the tenant ID to "common" but still facing the same issue

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

1 answer

Sort by: Most helpful
  1. AsithwMSFT 1,420 Reputation points Microsoft Vendor
    2023-11-26T01:46:51.39+00:00

    It might be because the Python script wasn't focused on the correct scope (Mail.Send)

    did you ensure the correct scope was granted?

    try decoding access token and check the scope value,

    0 comments No comments