Forum Discussion
NickMumby
Feb 14, 2025Copper Contributor
get SharePoint site items ID
I'm trying to extract all SharePoint News articles from my tenant. I'm almost there but struggling with the last step.
My initial graph call is this;
It returns all the news posts in a site
https://graph.microsoft.com/beta/sites/{SiteID}/pages/microsoft.graph.sitePage?$filter=createdDateTime gt 2025-01-01T00:00:00.0000000Z and promotionKind eq 'newsPost'
but there is no way of identifying if a post is published from that call, So I need to do a second call
https://graph.microsoft.com/v1.0/sites/{SiteID}/lists/{ListID}/items/{ItemID}/?expand=fields($select=*,FirstPublishedDate)
this expands a field 'FirstPublishedDate'. If it doesn't exist, the article has never been published.
My problem is I dont get the {ItemID} from the first call. this is the Id visible in the sharepoint list, e.g. 1,2,3 etc. not a GUID.
the output of my first graph call looks like this. How can I get the list item ID?
"value": [
{
"@odata.etag": "\"{404E5AC9-E35D-4895-8E89-E10BBA93B522},25\"",
"createdDateTime": "2024-12-16T15:37:08Z",
"description": "Hello everyone…",
"eTag": "\"{404E5AC9-E35D-4895-8E89-E10BBA93B522},25\"",
"id": "404e5ac9-e35d-4895-8e89-e10bba93b522",
"lastModifiedDateTime": "2024-12-16T15:43:50Z",
"name": "News-Article(4).aspx",
"webUrl": "https://company.sharepoint.com/functions/comms/SitePages/News-Article(4).aspx",
"title": "Merry Christmas - A message from ",
"pageLayout": "article",
"promotionKind": "newsPost",
"showComments": true,
No RepliesBe the first to reply