Frequently used REST APIs – Part 2

Hi All,
Greetings for the day!!!
While doing SharePoint / Power Platform / Teams development we most of the time need to use REST APIs and then need to google. This is the reason – birth of these series of articles. Thought to keep all REST APIs together so that whenever need can find quickly.
This is part 2 in series. First part is here – Frequently used REST APIs – Part 1
Get the SharePoint group ID or specific group details from group name
- Method : GET
_api/web/siteGroups/getByName('<GROUP NAME>')
OR
_api/web/sitegroups?$filter=LoginName eq '<GROUP DISPLAY NAME>'&$select=Id&top=1

https://knowledgejunction1.sharepoint.com/_api/web/siteGroups/getByName('Communication%20site%20Members')
Add user to SharePoint group
- Method : POST
_api/web/sitegroups(GroupID)/users
and in body of an action - "Send an HTTP request to SharePoint" we will specify the user claim as
{
"__metadata":{"type":'SP.User'},
'LoginName':'i:0#.f|membership|prasham@knowledgejunction1.onmicrosoft.com'
}

Get the root folder of your Shared Documents library
/_api/web/GetFolderByServerRelativeUrl('<document library folder relative URL>')
https://knowledgejunction1.sharepoint.com/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents')

Get all files in a folder – Get all files from Document library
/_api/web/GetFolderByServerRelativeUrl('<document library folder relative URL>')/Files
https://knowledgejunction1.sharepoint.com/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files

Get specific file from the document library – from name of file
https://knowledgejunction1.sharepoint.com/_api/web/GetFolderByServerRelativeUrl('<document library folder relative URL>')/Files('<file name>')
https://knowledgejunction1.sharepoint.com/_api/web/GetFolderByServerRelativeUrl('/Shared%20Documents')/Files('config.cfg')

Get specific file from the document library – from URL of file
/_api/web/GetFileByServerRelativeUrl('<file relative path>')
https://knowledgejunction1.sharepoint.com/_api/web/GetFileByServerRelativeUrl('/Shared%20Documents/config.cfg')

Fetch all files attached with List Item
https://{site_url}/_api/web/lists/getbytitle('{list_title}')/items({item_id})/AttachmentFiles/
Example
https://knowledgejunction1.sharepoint.com/_api/web/lists/getbytitle('Demo%20Email%20To%20SP%20Group')/items(1)/AttachmentFiles/

Fetch specific attachment file for given List Item
https://{site_url}/_api/web/lists/getbytitle('{list_title}')/items({item_id})/AttachmentFiles({attachment_name})
Example
https://knowledgejunction1.sharepoint.com/_api/web/lists/getbytitle('Demo%20Email%20To%20SP%20Group')/items(1)/AttachmentFiles('thumbnail.jpg')
Thanks for reading !!! If its worth at least reading once, kindly please like and share !! SHARING IS CARING 🙂
Enjoy the beautiful life !!! Have a FUN !!! HAVE A SAFE LIFE !!! TAKE CARE 🙂
1 Response
[…] Second part – Frequently used REST APIs – Part 2 […]
You must log in to post a comment.