How to get the @microsoft.graph.downloadUrl of news items

2024-09-17T08:34:15.89+00:00

I want to retrieve the four newest news items from a SharePoint site and get the temporary download URL of the first image in it's webParts. Somehow there does not seem to be a direct way to retrieve this, so I found a way in multiple steps:

First I retrieve the top 4 newest news items by calling this URL with the correct access token:

https://graph.microsoft.com/v1.0/sites/{siteId}/pages/microsoft.graph.sitePage?$expand=webParts&$filter=promotionKind%20eq%20'newsPost'&$top=4&$orderby=lastModifiedDateTime%20desc

Then I create a map for all found listId's and get all items of each listId using:

https://graph.microsoft.com/v1.0/sites/{siteId}/lists/{listId}/items?select=eTag,lastModifiedDateTime&expand=driveItem(select=@microsoft.graph.downloadUrl)&top=10000

I know you can get this in pages using skipToken but getting many at once is faster (but still slow).

Then I go through the webParts of the news items and match it's uniqueId with the eTags in the listmaps, if the eTag contains the uniqueId then I find the @microsoft.graph.downloadUrl. Problem of course is that it takes a long time to do this. I tried using "&orderby=lastModifiedDateTime%20desc", this changes the output somewhat but I don't get the newest items at the top (then I could do top=50 or something like that). Also I tried using a filter based on lastModifiedDateTime >= the oldest of the four news items) but I get all kinds of error messages so I don't know how to do that.

Please let me know if you have any idea to optimize this flow, thanks in advance!

Microsoft Graph
Microsoft Graph
A Microsoft programmability model that exposes REST APIs and client libraries to access data on Microsoft 365 services.
12,273 questions
SharePoint Development
SharePoint Development
SharePoint: A group of Microsoft Products and technologies used for sharing and managing content, knowledge, and applications.Development: The process of researching, productizing, and refining new or existing technologies.
3,044 questions
{count} votes

Accepted answer
  1. Xyza Xue_MSFT 25,546 Reputation points Microsoft Vendor
    2024-09-18T05:59:57.6033333+00:00

    Hi @Roel Plieger (Bossers & Cnossen BV) ,

    Thank you for posting in this community.

    Unfortunately, there does not seem to be a direct way to retrieve the @microsoft.graph.downloadUrl of news items. Personally, I completely agree with you, this is indeed a good addition to the current features of SharePoint. Thank you for bringing things to our attention. We sincerely recommend you go to SharePoint Feedback community to provide your feedback: SharePoint · Community (microsoft.com). This is the best platform to let related team hear from you and make the products and services better for you and others.


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

    Note: Please follow the steps in our documentation to enable e-mail notifications if you want to receive the related email notification for this thread.

    0 comments No comments

0 additional answers

Sort by: Most helpful

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.