Reasons for using the REST API
This post includes quite a few common requirements. So before I get started I’ll list some of the subjects that you might be interested in:
- Update a list item with the REST API
- Update a people field with the REST API
- Using the Send an HTTP request to SharePoint action
- Extra Bonus – Update the Modified By field!
Today I saw a question on the Flow forum “My flow is changing Modified By to me”. This is a common issue where people use one account to update the flows in Microsoft Flow and then all modified by accounts are set to the flow author.
Send an HTTP request to SharePoint
Although I might not be able to avoid it being set to the flow author, I might be able to set it back, although most likely you are updating the triggering item from within the flow. By using the Send an HTTP request to SharePoint action you might find that you have more control over the Modified By field.
I’m first of all assuming that you know who the user is that modified the list item (most likely this is the Modified By field before you updated the item within the flow!). In my example I’m assuming that the user Id of my user is 17. This number matches the user id as you can find it within SharePoint’s hidden user list (still remember that list?). For my test I simply went to modify a list item and then visited the …./items(13) url which gave me the user id of the user account that I was interested in. This of course could also be done within Microsoft Flow.
In the above screenshot you will notice that I’m updating the EditorId field rather than the Editor (this is the internal name for the Modified By field). Simply take your people field and add a postfix of Id.
Ok, that is easy! There is one important note however to update the Modified By user you will need to be site collection administrator. Therefore if you need a flow to update the Modified By user within your flow then you might want to create it as an administrator.