Would you like to replicate the news link feature in SharePoint online into your our custom solution? Well you can do it with ease by leveraging the _api/SP.Publishing.EmbedService/EmbedData endpoint. The endpoint has 3 query parameters that can be set:

  • url: string (URL that you would like to grab information from)
  • version: Int32 (Version of the news link, set to 1)
  • bannerImageUrl: boolean (Default is set to true when using the News Link feature in SharePoint)

The bannerImageUrl is not documented and does not appear in the SP.Publishing.EmbedService but upon testing this is what I found out:

  • Appears to only effect the Thumbnail property when using the service for SharePoint Pages.
  • When set to true it will return a link to the image at the getpreview.ashx endpoint which gives you an optimized image.
  • When set to false it will return a link to the image using SharePoint’s Rest API v2.1, the Graph API and is the full image.

The endpoint will return SP.Publishing.EmbedDataV1 type that you can parse to extract the data you need and and replicate this awesome feature in your solution.

Example of what is returned for an internal URL

json
{
"@odata.context": "https://anthonyepoulin.sharepoint.com/_api/$metadata#EmbedDataV1s/$entity",
"@odata.type": "#SP.Publishing.EmbedDataV1",
"@odata.id": "https://anthonyepoulin.sharepoint.com/_api/SP.Publishing.EmbedService/EmbedData",
"@odata.editLink": "SP.Publishing.EmbedService/EmbedData",
"AllowHttpsEmbed": false,
"CreatorName": "11;#Anthony Poulin,#i:0#.f|membership|anthony.poulin@anthonyepoulin.com,#anthony.poulin@anthonyepoulin.com,#anthony.poulin@anthonyepoulin.com,#Anthony Poulin",
"DatePublishedAt": "2020-10-12T12:08:27.0000000",
"Description": "Testing",
"EmbedServiceResponseCode": 0,
"ErrorMessage": null,
"Html": "<iframe width='100%' height='70%' src='https://anthonyepoulin.sharepoint.com/SitePages/My-Test-News.aspx' allowfullscreen></iframe>",
"ListId": "7074b169-aa57-4878-aa58-b379003a6fb6",
"PublisherName": "",
"ResponseCode": 0,
"SiteId": "e3d55621-dc75-4068-bd61-c008c063b0ee",
"ThumbnailUrl": "https://anthonyepoulin.sharepoint.com/_layouts/15/getpreview.ashx?guidSite=e3d55621-dc75-4068-bd61-c008c063b0ee&guidWeb=5b6acd05-3326-4e30-926a-73c6fc7b5c09&guidFile=6571e8b3-c408-4a84-adba-4cd4107cfeee",
"Title": "My Test News",
"Type": "rich",
"UniqueId": "6571e8b3-c408-4a84-adba-4cd4107cfeee",
"Url": "https://anthonyepoulin.sharepoint.com/SitePages/My-Test-News.aspx",
"VideoId": null,
"WebId": "5b6acd05-3326-4e30-926a-73c6fc7b5c09"
}

Example of what is returned for an external URL

json
{
"@odata.context": "https://anthonyepoulin.sharepoint.com/_api/$metadata#EmbedDataV1s/$entity",
"@odata.type": "#SP.Publishing.EmbedDataV1",
"@odata.id": "https://anthonyepoulin.sharepoint.com/_api/SP.Publishing.EmbedService/EmbedData",
"@odata.editLink": "SP.Publishing.EmbedService/EmbedData",
"AllowHttpsEmbed": false,
"CreatorName": "11;#Anthony Poulin,#i:0#.f|membership|anthony.poulin@anthonyepoulin.com,#anthony.poulin@anthonyepoulin.com,#anthony.poulin@anthonyepoulin.com,#Anthony Poulin",
"DatePublishedAt": "2020-10-12T12:08:27.0000000",
"Description": "Testing",
"EmbedServiceResponseCode": 0,
"ErrorMessage": null,
"Html": "<iframe width='100%' height='70%' src='https://anthonyepoulin.sharepoint.com/SitePages/My-Test-News.aspx' allowfullscreen></iframe>",
"ListId": "7074b169-aa57-4878-aa58-b379003a6fb6",
"PublisherName": "",
"ResponseCode": 0,
"SiteId": "e3d55621-dc75-4068-bd61-c008c063b0ee",
"ThumbnailUrl": "https://anthonyepoulin.sharepoint.com/_layouts/15/getpreview.ashx?guidSite=e3d55621-dc75-4068-bd61-c008c063b0ee&guidWeb=5b6acd05-3326-4e30-926a-73c6fc7b5c09&guidFile=6571e8b3-c408-4a84-adba-4cd4107cfeee",
"Title": "My Test News",
"Type": "rich",
"UniqueId": "6571e8b3-c408-4a84-adba-4cd4107cfeee",
"Url": "https://anthonyepoulin.sharepoint.com/SitePages/My-Test-News.aspx",
"VideoId": null,
"WebId": "5b6acd05-3326-4e30-926a-73c6fc7b5c09"
}
AaaS - Anthony as a Service