Friday, January 10, 2014

SharePoint 2013 Rest API Filter Document Library by Title, Id, AuthorId, EditorId, GUID

To Show all the requests Created by logged in user in a Document Library

(1) By Author/Logged in user:

//Finding Id by logged in user: (In jQuery Document ready function)

var userId = _spPageContextInfo.userId;
// alert("User Id is: " + userId);


"http://server/sites/subsite/_api/web/lists/getbytitle('DocLibName')/items?$select=Title,AuthorId, EditorId, Column1, Column2 &$filter= Author/Id eq " + userId

AuthorId = Created By
EditorId = Modified By
For filter use Author/Id 

(2) By Id
  --- 41 is the Id

(3) By Guid
http://Server/sites/Site/_api/Web/Lists(guid'YourLibraryGUID')/Items/?$select=Title,Column1,Column2 &$filter= Author/Id eq 2

 --- Displays items Created by user with Id 2