I have a bunch of images in a library that I need to get URLs for each item. I can get the GUIDs with this:
/sites/mysite/_api/web/lists/getbytitle('Rotating%20Banner')/items
Is there a way to quickly get URLs for each item.
SharePoint Stack Exchange is a question and answer site for SharePoint enthusiasts. It only takes a minute to sign up.
Sign up to join this communityI have a bunch of images in a library that I need to get URLs for each item. I can get the GUIDs with this:
/sites/mysite/_api/web/lists/getbytitle('Rotating%20Banner')/items
Is there a way to quickly get URLs for each item.
At least three options are available:
Option 1
Retrieve File Url via projected File
object:
/_api/Web/Lists/getByTitle('<list title>')/items?$select=File/ServerRelativeUrl&$expand=File
Option 2
Retrieve File Url via FileRef
property:
/_api/Web/Lists/getByTitle('<list title>')/items?$select=FieldValuesAsText/FileRef&$expand=FieldValuesAsText
Option 3
Retrieve files using GetFolderByServerRelativeUrl
endpoint:
/_api/Web/GetFolderByServerRelativeUrl('<list url>')/Files?$select=ServerRelativeUrl
Assuming it's a Document Library, you can use $expand to bring information from the File along with the query
Should be something like this:
/sites/mysite/_api/web/lists/getbytitle('Rotating%20Banner')/items?$select=Id,Title,File/ServerRelativeUrl&$expand=File