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

Brosk 0 Reputation points

i am using microsoft graph explorer to call this url :
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 '' 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

    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