Frequently used REST APIs – Part 2

fig : Power Automate - using "Send an HTTP request to SharePoint' action to add user to given SharePoint Group
fig : Power Automate - using "Send an HTTP request to SharePoint' action to add user to given SharePoint Group

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

fig : Power Automate - using "Send an HTTP request to SharePoint' action to get the GroupID from Group display name / login name
fig : Power Automate – using “Send an HTTP request to SharePoint’ action to get the GroupID from Group display name / login name

https://knowledgejunction1.sharepoint.com/_api/web/siteGroups/getByName('Communication%20site%20Members')

fig : Rest API Demo - Get the SharePoint group ID or specific group details from group name
fig : Rest API Demo – Get the SharePoint group ID or specific group details from group name

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'
}

fig : Power Automate - using "Send an HTTP request to SharePoint' action to add user to given SharePoint Group
fig : Power Automate – using “Send an HTTP request to SharePoint’ action to add user to given SharePoint Group

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') 

fig : SharePoint Online - REST API - Read the document library / Get root folder of Document Library
fig : SharePoint Online – REST API – Read the document library / Get root folder of Document Library

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

fig : SharePoint Online - REST API - Fetch all files from folder / Get all files from document library
fig : SharePoint Online – REST API – Fetch all files from folder / Get all files from document library

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')

fig : SharePoint Online - REST API - Fetch specific file from file name
fig : SharePoint Online – REST API – Fetch specific file from file name

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')

fig : SharePoint Online - REST API - Fetch specific file from file URL
fig : SharePoint Online – REST API – Fetch specific file from file URL

    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/ 

    fig : SharePoint Online - REST API - Fetch all attachments of given List Item
    fig : SharePoint Online – REST API – Fetch all attachments of given List Item

    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')

    fig : SharePoint Online - REST API - Fetching attachment by name of given List Item
    fig : SharePoint Online – REST API – Fetching attachment by name of given List Item

    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 🙂

    Prasham Sabadra

    LIFE IS VERY BEAUTIFUL. ENJOY THE WHOLE JOURNEY :) Founder of Microsoft 365 Junction, Speaker, Author, Learner, Developer, Passionate Techie. Certified Professional Workshop Facilitator / Public Speaker. Believe in knowledge sharing. Around 20+ years of total IT experience and 17+ years of experience in SharePoint and Microsoft 365 services Please feel free me to contact for any SharePoint / Microsoft 365 queries. I am also very much interested in behavioral (life changing) sessions like motivational speeches, Success, Goal Setting, About Life, How to live Life etc. My book - Microsoft 365 Power Shell hand book for Administrators and Beginners and 100 Power Shell Interview Questions - https://www.amazon.in/Microsoft-Administrators-Beginners-Interview-Questions/dp/9394901639/ref=tmm_pap_swatch_0?_encoding=UTF8&qid=1679029081&sr=8-11

    You may also like...

    3 Responses

    Leave a Reply

    This site uses Akismet to reduce spam. Learn how your comment data is processed.

    Discover more from Microsoft 365

    Subscribe now to keep reading and get access to the full archive.

    Continue reading