2

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.

7

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 
  • How do you know what to put for $expand? – matt Oct 20 '14 at 15:28
  • I usually prefer to use Postman REST client to explore entity properties instead of msdn documentation – Vadim Gremyachev Oct 20 '14 at 15:41
4

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

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service, privacy policy and cookie policy

Not the answer you're looking for? Browse other questions tagged or ask your own question.