3

Few questions about sharepoint restful API for document library

  1. There is no single restful call to retrieve items of a specific view, right?

  2. Now I called /fields to get all fields that are FieldTypeKind==20 (User), then I call /ViewFields to construct the query with expanding, finally call /items to get items. Is it correct?

  3. calling /items can get all fields that I can saw on doclib web part, but there is no URL for files. Calling /files have no field I can use to match the items from /items, how to fix it?

Thanks From Peter

  • Thank you all, i think i had a big mistake about learning sharepoint restful api. I found out it is base on oData and oData should provide the ability to link up different resources, in my case, it should has a way to link up items and files, rather than we call every single APIs and combine the data ourselves. I will do some research on it. Thank you for you time. – Peter Cheung Dec 25 '17 at 14:30
  • @PeterCheung Please don't forget to upvote the helpful answer and Mark the correct one from the below answers Thanks! – Mohamed El-Qassas MVP Jan 15 '18 at 8:24
1

The following are applicable to both list/library as appropriate

  1. NO RESTFull api available to get items view based.
  2. Yes, Always column which holder more or collection of metadata I can be accessed using $select and $expand https://webapplication.com/_api/web/lists/getbytitle('Issues')/items?$filter=ID eq 1&$select=Title,Editor/Title&$expand=Editor/Title

Check here for MSDN documentation.

  1. $select and $expand would work for document libraries as well. However, there is a slight difference while calling API for doc libs like below
_api/Web/GetFolderByServerRelativeUrl('folderRelativeUrl')?$expand=Folders,Files

(or)

_api/Web/GetFolderByServerRelativeUrl('folderRelativeUrl')?$expand=Files,Folders/Files,Folders/Folders/Files

Refer here for more info.

  • i found something crazy: /items/$filter=GUID eq (guid'efee39c7-ae90-434a-9174-9a9bd7411c74') which works great, but fail to filter the uniqueId /items/$filter=UniqueId eq (guid’asdas9c7-1290-4123-9174-9a9bd7411c74') will return empty json. Althought i can't filter the uniqueId, but i can select it – Peter Cheung Dec 25 '17 at 8:07
  • What is the datatype of GUID column? If it is a string compare like string without typecasting. – little_big_thoughts Dec 25 '17 at 9:12
0

1.We can get list item of a list view using REST API + CAML Query.

/_api/web/lists/getbytitle('DocumentLibrary')/getitems

Check the article below:

https://stackoverflow.com/questions/26884647/using-rest-to-fetch-sharepoint-view-items

2.To get user field from list items, we can use like this:

/_api/web/lists/getbytitle('DocumentLibrary')/items?$select=Users/Title&$expand=Users/Id

More information: https://social.technet.microsoft.com/wiki/contents/articles/31210.sharepoint-2013-get-user-details-from-person-or-group-field-using-rest-api.aspx

3.To get files url, we can use this:

/_api/web/lists/getbytitle('DocumentLibrary')/items?$select=FileRef

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.