I'm retrieving the JSON representation of a SharePoint page using the endpoint:
GET .0/sites/${siteId}/pages/${pageId}/microsoft.graph.sitePage?expand=canvasLayout&select=id,name,webUrl,title,description,createdBy,canvasLayout,parentReference
I receive a JSON structure like this.
{
"@odata.type": "#microsoft.graph.standardWebPart",
"id": "e90803f3-30a5-4ef5-8c7e-1056966a2930",
"webPartType": "b4cc345e-35ed-4b30-bc91-a7d6d249494f",
"data": {
"dataVersion": "1.3",
"description": "This is an example description.",
"title": "Stream",
"properties": {
"label": "This is an example property",
"isTitleEnabled": true,
"templateId": 1,
"maxItemsPerPage": 3,
"maxRowsPerPageGrid": 5,
"maxRowsPerPageTheater": 1,
"hideWebPartWhenEmpty": true,
"sourceType": "VIDEO",
"listSortField": "Created",
"playlistSortField": "Default",
"isPlaceholderState": false,
"dataProviderId": "StreamVideo",
"layoutId": "Theater",
"webId": "cf329d30-484e-4b9f-9378-533152cfcd3f",
"siteId": "6688e890-8000-4a19-9839-905b54adb407",
"spWebUrl": ";,
"previewUrl": ".1/sites/example.sharepoint,6688e890-8000-4a19-9839-905b54adb407,cf329d30-484e-4b9f-9378-533152cfcd3f/lists/9b049de0-9a77-4169-bd45-6dc32cf99264/items/e2ae18de-a4f2-412d-a5c8-b8e340ef9e90/driveItem/thumbnails/0/c400x99999/content?prefer=noRedirect,extendCacheMaxAge&clientType=modernWebPart",
"videoDuration": 145100000,
"listId": "9b049de0-9a77-4169-bd45-6dc32cf99264",
"rootFolder": "/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"uniqueId": "e2ae18de-a4f2-412d-a5c8-b8e340ef9e90",
"listTitle": "Title Example",
"serverRelativePath": "/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"link": " Documents/ExampleFolder/movie.mp4",
"wopiurl": "/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"serverRelativeUrl": "/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"webAbsoluteUrl": ";,
"file": " Documents/ExampleFolder/movie.mp4",
"query": {
"@odata.type": "#graph.Json",
"contentLocation": 1,
"[email protected]": "#Collection(Int32)",
"contentTypes": [
3
],
"[email protected]": "#Collection(Int32)",
"documentTypes": [
11
],
"sortType": 6
},
"displayMaps": {
"1": {
"@odata.type": "#graph.Json",
"cardType": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"CardType"
]
},
"telemetryProperties": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"TelemetryProperties"
]
},
"accentColor": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"AccentColor"
]
},
"initials": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"Initials"
]
},
"previewUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"PreviewUrl",
"PictureThumbnailURL"
]
},
"headingText": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"SiteTitle"
]
},
"itemUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"WebPath"
]
},
"listItemId": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"listItemId"
]
},
"iconUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"IconUrl"
]
},
"activity": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ModifiedDate"
]
},
"spWebUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"SPWebUrl"
]
},
"uniqueId": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"UniqueID"
]
},
"imageOverlapText": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ImageOverlapText"
]
},
"fileExt": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"FileType"
]
},
"tipActionButtonIcon": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"TipActionButtonIcon"
]
},
"className": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ClassName"
]
},
"tipActionLabel": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"TipActionLabel"
]
},
"imageOverlapTextAriaLabel": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ImageOverlapTextAriaLabel"
]
},
"name": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"Name"
]
},
"personImageUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ProfileImageSrc"
]
},
"title": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"UserName",
"Title"
]
}
},
"@odata.type": "#graph.Json"
}
},
"serverProcessedContent": {
"htmlStrings": [],
"searchablePlainTexts": [
{
"key": "title",
"value": "example_value"
}
],
"links": [
{
"key": "baseUrl",
"value": "/sites/SiteExample"
}
],
"imageSources": []
}
}
}
From the response, I parse out file metadata that’s attached to the page. For each file, I extract the following fields from data.properties:
uniqueId
listId
siteId
Then I attempt to retrieve detailed information about the file using the request:
GET .0/sites/${siteId}/lists/${listId}/items/${uniqueId}/driveItem?select=id,size,parentReference,name,webUrl,file,createdBy,folder
This request works for most files. However, for some files—despite having the correct uniqueId, listId, and siteId and even when I can manually verify that the file exists—the request returns a 404 error. I need the detailed JSON response mainly to obtain the webUrl to download the file.
My questions are:
Why might some files return a 404 even though their metadata appears correct?
What alternative approach (e.g., using a different endpoint) can I
use to reliably obtain the full JSON details for these file attachments?
Any insights or suggestions would be appreciated.
I'm retrieving the JSON representation of a SharePoint page using the endpoint:
GET https://graph.microsoft/v1.0/sites/${siteId}/pages/${pageId}/microsoft.graph.sitePage?expand=canvasLayout&select=id,name,webUrl,title,description,createdBy,canvasLayout,parentReference
I receive a JSON structure like this.
{
"@odata.type": "#microsoft.graph.standardWebPart",
"id": "e90803f3-30a5-4ef5-8c7e-1056966a2930",
"webPartType": "b4cc345e-35ed-4b30-bc91-a7d6d249494f",
"data": {
"dataVersion": "1.3",
"description": "This is an example description.",
"title": "Stream",
"properties": {
"label": "This is an example property",
"isTitleEnabled": true,
"templateId": 1,
"maxItemsPerPage": 3,
"maxRowsPerPageGrid": 5,
"maxRowsPerPageTheater": 1,
"hideWebPartWhenEmpty": true,
"sourceType": "VIDEO",
"listSortField": "Created",
"playlistSortField": "Default",
"isPlaceholderState": false,
"dataProviderId": "StreamVideo",
"layoutId": "Theater",
"webId": "cf329d30-484e-4b9f-9378-533152cfcd3f",
"siteId": "6688e890-8000-4a19-9839-905b54adb407",
"spWebUrl": "https://example.sharepoint/sites/ExampleSite",
"previewUrl": "https://example.sharepoint/_api/v2.1/sites/example.sharepoint,6688e890-8000-4a19-9839-905b54adb407,cf329d30-484e-4b9f-9378-533152cfcd3f/lists/9b049de0-9a77-4169-bd45-6dc32cf99264/items/e2ae18de-a4f2-412d-a5c8-b8e340ef9e90/driveItem/thumbnails/0/c400x99999/content?prefer=noRedirect,extendCacheMaxAge&clientType=modernWebPart",
"videoDuration": 145100000,
"listId": "9b049de0-9a77-4169-bd45-6dc32cf99264",
"rootFolder": "/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"uniqueId": "e2ae18de-a4f2-412d-a5c8-b8e340ef9e90",
"listTitle": "Title Example",
"serverRelativePath": "/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"link": "https://example.sharepoint/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"wopiurl": "/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"serverRelativeUrl": "/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"webAbsoluteUrl": "https://example.sharepoint/sites/ExampleSite",
"file": "https://example.sharepoint/sites/ExampleSite/Shared Documents/ExampleFolder/movie.mp4",
"query": {
"@odata.type": "#graph.Json",
"contentLocation": 1,
"[email protected]": "#Collection(Int32)",
"contentTypes": [
3
],
"[email protected]": "#Collection(Int32)",
"documentTypes": [
11
],
"sortType": 6
},
"displayMaps": {
"1": {
"@odata.type": "#graph.Json",
"cardType": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"CardType"
]
},
"telemetryProperties": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"TelemetryProperties"
]
},
"accentColor": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"AccentColor"
]
},
"initials": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"Initials"
]
},
"previewUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"PreviewUrl",
"PictureThumbnailURL"
]
},
"headingText": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"SiteTitle"
]
},
"itemUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"WebPath"
]
},
"listItemId": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"listItemId"
]
},
"iconUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"IconUrl"
]
},
"activity": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ModifiedDate"
]
},
"spWebUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"SPWebUrl"
]
},
"uniqueId": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"UniqueID"
]
},
"imageOverlapText": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ImageOverlapText"
]
},
"fileExt": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"FileType"
]
},
"tipActionButtonIcon": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"TipActionButtonIcon"
]
},
"className": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ClassName"
]
},
"tipActionLabel": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"TipActionLabel"
]
},
"imageOverlapTextAriaLabel": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ImageOverlapTextAriaLabel"
]
},
"name": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"Name"
]
},
"personImageUrl": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"ProfileImageSrc"
]
},
"title": {
"@odata.type": "#graph.Json",
"[email protected]": "#Collection(String)",
"sources": [
"UserName",
"Title"
]
}
},
"@odata.type": "#graph.Json"
}
},
"serverProcessedContent": {
"htmlStrings": [],
"searchablePlainTexts": [
{
"key": "title",
"value": "example_value"
}
],
"links": [
{
"key": "baseUrl",
"value": "/sites/SiteExample"
}
],
"imageSources": []
}
}
}
From the response, I parse out file metadata that’s attached to the page. For each file, I extract the following fields from data.properties:
uniqueId
listId
siteId
Then I attempt to retrieve detailed information about the file using the request:
GET https://graph.microsoft/v1.0/sites/${siteId}/lists/${listId}/items/${uniqueId}/driveItem?select=id,size,parentReference,name,webUrl,file,createdBy,folder
This request works for most files. However, for some files—despite having the correct uniqueId, listId, and siteId and even when I can manually verify that the file exists—the request returns a 404 error. I need the detailed JSON response mainly to obtain the webUrl to download the file.
My questions are:
Why might some files return a 404 even though their metadata appears correct?
What alternative approach (e.g., using a different endpoint) can I
use to reliably obtain the full JSON details for these file attachments?
Any insights or suggestions would be appreciated.
Share Improve this question asked Apr 1 at 21:19 thewildman97thewildman97 113 bronze badges1 Answer
Reset to default 0@thewildman97 Use GET /drives/{driveId}/items/{uniqueId}
If you already have the file’s unique ID (a DriveItem ID or SharePoint file ID), then:
GET https://graph.microsoft/v1.0/sites/{siteId}/drive/items/{uniqueId}
Or, better yet, if you want to use the path (e.g., serverRelativePath or serverRelativeUrl), you can:
Use the path-based drive/root: endpoint
GET https://graph.microsoft/v1.0/sites/{siteId}/drive/root:{serverRelativePath}
Example:-
GET https://graph.microsoft/v1.0/sites/{siteId}/drive/root:/Shared Documents/ExampleFolder/movie.mp4
This is often more reliable when dealing with paths you already parsed from serverRelativeUrl or file.
It avoids ambiguity with GUID vs. item ID mismatches.