This post is a collection of REST endpoints which are very helpful in performing various operations in SharePoint. Sometimes while working on projects we come across various scenarios where we have to use REST but we don’t know if such thing is possible or not using REST or whether any endpoint is available in REST for this.
I will try to cover some scenarios where i used REST and they are pretty useful and easy to use. I will keep on updating this post as and when possible.
If you know some endpoints which are really very useful and are not mentioned in this post, you can suggest them in comments. I will try to incorporate it in my post.
Endpoints that are helpful in read operation map to HTTP GET. Update operation map to HTTP POST, for Update and Insert operations map to HTTP PUT and to Delete SharePoint object it maps to HTTP DELETE.
List Operations:
- Url to get all items:
/_api/Web/Lists/GetByTitle(‘List Title’)/Items
- Select query on List to get Selected Items:
/_api/Web/Lists/GetByTitle(”List Title)/Items?$select=column1,column2
- To get user details like ‘FirstName’, ‘LastName’, ‘EMail’, etc for a Person/Group field of SharePoint List we need to make use of ‘expand’ in REST API. In REST API we get id instead of actual value because person/group field is a lookup field internally.
/_api/Web/Lists/GetByTitle(‘List Title’)/Items?$select=column1,column2,column3/EMail&$expand=column3/Id
- Get Attachment from List Item
_api/Web/Lists/GetByTitle(‘UserData’)/items?$select=AttachmentFiles&$expand=AttachmentFiles
Working With Libraries
- You can retrieve the root folder of your Document Library using the following endpoint:
/_api/web/GetFolderByServerRelativeUrl(‘/Shared Documents’)
- To retrieve all files in a folder:
/_api/web/GetFolderByServerRelativeUrl(‘/Shared Documents’)/Files
- To retrieve a specific file:
/_api/web/GetFolderByServerRelativeUrl(‘/Shared Documents’)/Files(‘Test.docx’)
Get User Properties with REST api
- Get properties of current user
_api/SP.UserProfiles.PeopleManager/GetMyProperties
- Get specific properties for current user
_api/SP.UserProfiles.PeopleManager/GetMyProperties?$select=Email,DisplayName,PictureUrl,AccountName