Calling the same OneDrive graph API will be successful for some accounts and will fail for some accounts.

QA1 5 Reputation points
2024-09-30T13:46:32.3166667+00:00

Use different accounts to call the same OneDrive graph API and other parameters (such as client_ID, client_secret) are same,

Account "A" will fail at Step 3, and Account "A" was created before 2019/11,

Account "B" will all succeed and Account "B" was created recently.

Account "A" and "B" can use OneDrive on the web and they are all personal accounts.

Step1. login in

Request:
https://login.microsoftonline.com/common/oauth2/v2.0/authorize?client_id=653c1.....&response_type=code&redirect_uri=http://localhost:53511/cloud&response_mode=query&scope=Files.ReadWrite+offline_access

Redirect:
http://localhost:53511/cloud?code=M.C558_BL2.2.U.be6bddb7-edac-688f-b6d6-f76890c6aad8

Step2. Get token

POST /common/oauth2/v2.0/token HTTP/2
Host: login.microsoftonline.com
user-agent: curl/7.81.0
accept: */*
content-type: application/x-www-form-urlencoded
content-length: 258

client_id=653c1... scope=Files.ReadWrite+offline_access code=M.C558_BL2.2.U.... redirect_uri=http://localhost:53511/cloud grant_type=authorization_code client_secret=yzlW82... 


HTTP/2 200 
cache-control: no-store, no-cache
pragma: no-cache
content-type: application/json; charset=utf-8
expires: -1
strict-transport-security: max-age=31536000; includeSubDomains
x-content-type-options: nosniff
p3p: CP="DSP CUR OTPi IND OTRi ONL FIN"
x-ms-request-id: 8b61db84-5d4a-4a5f-99b5-31832f964300
x-ms-ests-server: 2.1.19005.8 - SEASLR1 ProdSlices
x-ms-srs: 1.P
x-xss-protection: 0
set-cookie: fpc=Agzud9KEFKNOkh2ZjZh1DBn-zW_gAQAAAJWSjN4OAAAA; expires=Wed, 30-Oct-2024 12:37:42 GMT; path=/; secure; HttpOnly; SameSite=None
set-cookie: x-ms-gateway-slice=estsfd; path=/; secure; samesite=none; httponly
set-cookie: stsservicecookie=estsfd; path=/; secure; samesite=none; httponly
date: Mon, 30 Sep 2024 12:37:42 GMT
content-length: 1670

{"token_type":"Bearer","scope":"Files.ReadWrite","expires_in":3600,"ext_expires_in":3600,"access_token":"EwB4A8l6BA......","refresh_token":"M.C558_BL2.0......"}

Step3. Call OneDrive graph API. Account "A" will fail. The account "A" created early than 2019/11

POST /v1.0/me/drive/items/root:/Scan/ttttt.jpg:/createUploadSession HTTP/2
Host: graph.microsoft.com
user-agent: curl/7.81.0
accept: */*
content-type: application/json
authorization: Bearer EwB4A8l6BAAUbDba3x2OMJE......
content-length: 157

{"item":{"@microsoft.graph.conflictBehavior":"rename","description":"","fileSystemInfo":{"@odata.type":"microsoft.graph.fileSystemInfo"},"name":"ttttt.jpg"}}



HTTP/2 400 
cache-control: no-store, no-cache, max-age=0, private
content-type: application/json
strict-transport-security: max-age=31536000
request-id: 9c768b04-0dfd-41d1-a3f0-69c223536fa6
client-request-id: 9c768b04-0dfd-41d1-a3f0-69c223536fa6
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Korea Central","Slice":"E","Ring":"4","ScaleUnit":"000","RoleInstance":"SE1PEPF000092F9"}}
date: Mon, 30 Sep 2024 12:52:58 GMT

{"error":{"code":"invalidRequest","message":"Invalid request","innerError":{"date":"2024-09-30T12:52:59","request-id":"9c768b04-0dfd-41d1-a3f0-69c223536fa6","client-request-id":"9c768b04-0dfd-41d1-a3f0-69c223536fa6"}}}

Step3. Call OneDrive graph API. Account "B" will succeed and Account "B" was created recently.

POST /v1.0/me/drive/items/root:/Scan/ttttt.jpg:/createUploadSession HTTP/2
Host: graph.microsoft.com
user-agent: curl/7.81.0
accept: */*
content-type: application/json
authorization: Bearer EwB4A8l6BAAUbDba3x2OMJE......
content-length: 157

{"item":{"@microsoft.graph.conflictBehavior":"rename","description":"","fileSystemInfo":{"@odata.type":"microsoft.graph.fileSystemInfo"},"name":"ttttt.jpg"}}


HTTP/2 200 
cache-control: no-store
content-type: application/json;odata.metadata=minimal;odata.streaming=true;IEEE754Compatible=false;charset=utf-8
location: https://graph.microsoft.com
strict-transport-security: max-age=31536000
request-id: ef27052d-7cf7-4a15-97b2-a1f8af95c483
client-request-id: ef27052d-7cf7-4a15-97b2-a1f8af95c483
x-ms-ags-diagnostic: {"ServerInfo":{"DataCenter":"Korea Central","Slice":"E","Ring":"4","ScaleUnit":"003","RoleInstance":"SE1PEPF00009317"}}
odata-version: 4.0
date: Mon, 30 Sep 2024 13:16:09 GMT

{"@odata.context":"https://graph.microsoft.com/v1.0/$metadata#microsoft.graph.uploadSession","expirationDateTime":"2024-10-05T13:17:50.988Z","nextExpectedRanges":["0-"],"uploadUrl":"https://api.onedrive.com/rup/1fe3b5cce115f141/eyJSZXNvdXJjZUlEIjoiMUZFM0......"}

Why does account "A" fail but account "B" succeed, other parameters and operations are same

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,241 questions
OneDrive
OneDrive
A Microsoft file hosting and synchronization service.
1,138 questions
Microsoft Entra ID
Microsoft Entra ID
A Microsoft Entra identity service that provides identity management and access control capabilities. Replaces Azure Active Directory.
22,058 questions
0 comments No comments
{count} vote

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.