Graph API: How to find the download URL for files in Sharepoint content or the bannerImage

FV 0 Reputation points
2023-02-01T15:55:52.74+00:00

When I do the call https://graph.microsoft.com/v1.0/sites/[site-id]/lists/[list-id]/items?expand=fields(select=CanvasContent1,Title,BannerImageUrl) the response

"BannerImageUrl": {        
"Description": "https://[name].sharepoint.com/_layouts/15/getpreview.ashx?path=%2FSiteAssets%2FSitePages%2Fnrzh85no%2FNiceImage.jpg"",
"Url": "https://[name].sharepoint.com/_layouts/15/getpreview.ashx?path=%2FSiteAssets%2FSitePages%2Fnrzh85no%2FNiceImage.jpg"
 }


How can I get the download URL for this image?

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,113 questions
SharePoint
SharePoint
A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.
10,740 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. HarmeetSingh7172 4,811 Reputation points
    2023-02-01T22:10:39.0033333+00:00

    Hello @FV

    Thanks for reaching out!

    To download the file uploaded in document library (referred as driveItem), use Drive Item Get Content Graph API.

    GET /sites/{site-id}/drives/{drive-id}/root:/{path-relative-to-root}:/content  
    GET /sites/{site-id}/drives/{drive-id}/items/{item-id}/content 
    

    To download file/image uploaded to a list Item (referred as itemAttachment), currently Microsoft Graph doesn't have support for list item attachments, you can upvote feature requested submitted by other Graph users.

    Add support for SharePoint List Item Attachments in Graph


    Hope this helps.
    If the answer is helpful, please click "Accept Answer" and kindly upvote it. If you have extra questions about this answer, please click "Comment".


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.