Greetings
Good day everyone, Hoping you all have a nice weekend. Today I’m gonna introduce you one of most powerful action of Power Automate, especially when you’re creating flow that related with SharePoint. This action is well-know and used by many experts. But in this blog post, I will give you a cheat sheet where you can follow, even you’re not an expert.
Prologue
You may familiar with SharePoint action in Power Automate, there are many out-of-the-box action that can perform general task like Get item, Get items, Create item, Update Item, Delete item, Create file, Delete file, and more.
But if you ever wonder, How it work? How Power Automate tell with SharePoint to do these task?
All of those action do is send HTTP request to SharePoint REST API.
While these out-of-the-box action can perform almost task and should cover almost thing you need, but yes, That’s not total task they can do.
SharePoint REST API have tons of functionalities which sometimes provide better result than out-of-the box action, even when doing the same task.
Now, It’s time to show you. Here is a list of my cheat sheet!
Table of Contents
- README
- Get item (Specific record by ID)
- Select only columns you need
- Expand LookUp column
- Expand Person column
- Get items (Multiple record)
- Filter list item
- Create item
- Update list item
- Delete list item
- Get SharePoint attachments
- Get drive id of SharePoint document library
0. README
– Make sure to replace ListTitle with the name of your list.
– Make sure to replace ID with your item ID.
– You can add Accept: application/json; odata=nometadata at headers to get rid of unwanted metadata.
1. Get item (Specific record by ID)
Purpose: To get a single record of item in a list, specify by ID
Alternative of: Get item
Method: GET
Uri: _api/web/lists/GetByTitle(‘ListTitle‘)/items(ID)
2. Select only columns you need
Purpose: To only select column that you really need,
Supported with: Every GET request
Syntax: $select=ColumnName1, ColumnName2, …
3. Expand LookUp column
Purpose: To expand LookUp column, and the best things is you can expand all column from the source list for LookUp column, not just the Value and Id
Supported with: Every GET request
Syntax: $expand=ColumnName$select=ColumnName/Field1,ColumnName/Field2,ColumnName/Field3,…
4. Expand Person column
Purpose: To expand Person column
Supported with: Every GET request
Syntax: $expand=ColumnName$select=ColumnName/Field1,ColumnName/Field2,ColumnName/Field3,…
5. Get items (Multiple record)
Purpose: To get a one or more record of items in a list. It will return only first 100 records by default but can set to max 5,000 using $top
Alternative of: Get items
Method: GET
Uri: _api/web/lists/GetByTitle(‘ListTitle‘)/items
6. Filter list item
Purpose: To filter list column using OData query
Supported with: Every GET request for one or more record
Syntax: $filter=ColumnName eq ‘Value’
7. Create item
Purpose: To create item in SharePoint List, The good (or bad) things is by using this method, it can bypass SharePoint required field validation!
Alternative of: Create item
Method: POST
Uri: _api/web/lists/GetByTitle(‘ListTitle‘)/items
Body: JSON Object of your item
8. Update list item
Purpose: To update existing list item, Unlike the “Update item” action, you can specify just only the column you want to update without need to specify the required field
Alternative of: Update Item
Method: POST
Headers: {“X-HTTP-METHOD”: “MERGE“, “IF-MATCH”: “*”}
Uri: _api/web/lists/GetByTitle(‘ListTitle‘)/items(ID)
Body: JSON Object you want to update
9. Delete list item
Purpose: To delete existing list item
Alternative of: Delete Item
Method: POST
Headers: {“X-HTTP-METHOD”: “DELETE“, “IF-MATCH”: “*”}
Uri: _api/web/lists/GetByTitle(‘ListTitle‘)/items(ID)
10. Get SharePoint attachments
Purpose: To get a list of attachments of SharePoint item
Supported with: Every GET request of SharePoint items
Syntax: $select=AttachmentFiles,Title&$expand=AttachmentFiles
11. Get drive id of SharePoint document library
Purpose: To get a drive id of SharePoint document library which sometimes needed for some action (some action don’t accept library id or library name)
Alternative of: –
Method: GET
Uri: _api/v2.1/drives?$select=id,name
And there are tons of capabilities of what SharePoint REST API can do!
While I can’t cover all and go in details for every capabilities in cheat sheet, I recommend you to check out these amazing blog post that leverage SharePoint REST API.