SharePoint REST API URL for accessing List items,documents,assign permission in list, document libraries, Search and user profile property
List related RES API
- To get all List items
https://{site Url}/_api/web/lists/getbytitle(‘Employee Leave Requests’)/items
- To get Item by ID
https://{site Url}/_api/web/lists/getbytitle(‘Employee Leave Requests’)/items(1)
- To filter using a column
https://{site Url}/_api/web/lists/getbytitle(‘Employee Leave Requests’)/items(1)?$filter=Title eq ‘sample’
- To filter using multiple column
https://{site Url}/_api/web/lists/getbytitle(‘Employee Leave Requests’)/items(1)?$filter=(Title eq ‘sample’) and (Name eq ‘sivam’)
- To Filter using date column
https://{site Url}/_api/web/lists/getbytitle(‘Employee Leave Requests’)/items(1)?$filter= (Created ge ‘6/7/2016’) and (Created le ‘6/7/2016’)
- To filter using date and time, datetime should be iso formatted
https://{site Url}/_api/web/lists/getbytitle(‘Employee Leave Requests’)/items(1)?$filter= (Created ge datetime’2016-06-08T07:00:00Z’) and (Created le datetime’2016-06-08T18:29:00Z’)
- Breaking role inheritance (HTTP POST)
https://{site Url}/_api/web/lists/getbytitle(‘Sample’)/items(1)/breakroleinheritance(true)
- To get all assigned permission of item
https://{site Url}/_api/web/lists/getbytitle(‘Employee Leave Requests’)/items(1)/roleassignments
- To remove permission of user for the item(HTTP DELETE)
https://{site Url}/_api/web/lists/getbytitle(‘Employee Leave Requests’)/items(1)/roleassignments/getbyprincipalid(“Id of the user to whom permission to be removed ”)
- To assign permission for the group/user for particular item –(HTTP POST)
https://{site Url}/_api/web/lists/getbytitle(‘Employee Leave Requests’)/items(1)/roleassignments/addroleassignment(principalid”{Id of the user/group to whom permission to be assigned}”,roleDefId=1073741926(Permission id))—HTTP post action
- To get all role definitions of the site
{SiteURL}/_api/web/roledefinitions
- To filter using the people picker column
https://{site Url}/_api/web/lists/getbytitle(‘Employee%20Leave%20Requests’)/items?$select=EmployeeName/EMail,LeaveEndDate,Created &$expand=EmployeeName/EMail&$filter=(EmployeeName/EMail eq ‘manager@****.onmicrosoft.com’)
- To filter using the look up column
https://{site Url}/_api/web/lists/getbytitle(‘Employee%20Leave%20Requests’)/items $select=Title,Employer/Id&$expand=Employer/Id&$filter=Employer/Id eq 1
Rest API url to access people search results
- https://**********.sharepoint.com/_api/search/query?querytext=’*’&sourceid=’b09a7990-05ea-4af9-81ef-edfab16c4e31–> access people search results
- https://************.sharepoint.com/_api/search/query?querytext=’*’&sourceid=’b09a7990-05ea-4af9-81ef-edfab16c4e31&selectproperties=’Dotted-line Manager’ to Select the properties.
Document Library rest API
- To get document uploaded count inside the particular folder
- To get all the documents/files
https://{site Url}/_api/Web/GetFolderByServerRelativeUrl(‘Lists/ {DocLibName }/{folder url}’)/Files return all files
- To get the properties of particular document
https://{site Url}/_api/Web/GetFolderByServerRelativeUrl(‘Lists/{DocLibName }/{folder url}’)/ListItemAllFields?$Select=Id
- To assign specific permission of folder in document library
First breaking inheriting permission of that folder (HTTP Post)
https://{site Url}/_api/web/GetFolderByServerRelativeUrl(‘Lists/{DocLibName }/{folder url}’)/ListItemAllFields/breakroleinheritance(true)
Removing the pre assigned permission for that folder (HTTP DELETE)
https://{site Url}/_api/web/GetFolderByServerRelativeUrl(‘Lists/{DocLibName }/{folder url}’)/ListItemAllFields/roleassignments/getbyprincipalid({User or group id})
Assigning permission for folder (HTTP Post)
https://{site Url}/_api/web/GetFolderByServerRelativeUrl(‘Lists/{DocLibName }/{folder url}’)/ListItemAllFields/roleassignments/addroleassignment(principalid={User or group id},roleDefId={Role definition id})
- Check folder exists,Call the below url if response is ok folder exists or else you will receive a error
https://{site Url}/_api/Web/GetFolderByServerRelativeUrl((‘Lists/{DocLibName }/{folder url}’)
User Profile Properties
- To get user profile properties
https://{site Url}/_api/SP.UserProfiles.PeopleManager/GetUserProfilePropertyFor(accountName=@v,propertyName=’Manager’)?@v=’i:0%23.f|membership|******@*******.onmicrosoft.com’
Rest API Limitation
Rest API URL should not exceed 299.If exceeds the server won’t respond max length is 299.
Comments
Post a Comment