Home > Back-end >  Sharepoint rest api get shortcuturl
Sharepoint rest api get shortcuturl

Time:12-11

I am able to connect to the Sharepoint REST api, all good, I am missing one important property, which I think is present, but probably hidden somewhere. I am fetching details of an item like this

https://myco.sharepoint.com/teams/Intranet/_api/web/lists/getbytitle('Site Pages')/items?$orderby=Modified desc&$top=11&$select=Title,Id,Description,BannerImageUrl,Properties/vti_x005f_shortcuturl&$expand=Properties

What I've read is that Properties/vti_x005f_shortcuturl should give me the result, however; this object is empty in my response:

{
"Properties": {},
"Id": 1567,
"Title": "This is awesome",
"BannerImageUrl": {
    "Description": "https://myco.sharepoint.com/_layouts/15/getpreview.ashx?path=/teams/Intranet/SiteAssets/SitePages/98z8hx4c/1426231370-nuno-dash.jpg&ow=1920&oh=1080",
    "Url": "https://myco.sharepoint.com/_layouts/15/getpreview.ashx?path=/teams/Intranet/SiteAssets/SitePages/98z8hx4c/1426231370-nuno-dash.jpg&ow=1920&oh=1080"
 },
 "Description": "December 3 is International Day of Persons with Disabilities (IDPD)",
 "ID": 1567
 }
 //omitted rest of results

I would like to have a url: 'https://gotothewebversion' so when displaying the result somebody can click on the link and go to the article.

EDIT: On 1 particular item the Properties is filled, but there is no shortcutUrl.

Somebody has a clue how to achieve this?

cheers

CodePudding user response:

I was able to retrieve a URL link to the file by expanding "File" in the REST query and then selecting File/ServerRelativeUrl.

$expand=File&$select=*, File/Name, File/ServerRelativeUrl
  • Related