“I’m trying to update SharePoint people picker field using user id, but the Power Automate http request keeps telling me the no user doesn’t exist!”
If you’re like me and use a lot of http requests to SharePoint, you might find that working with users can be sometimes challenging. It’s because of the variety for these requests. Sometime you need just the user email, other time you need the whole claims login, or even the SP site principal id. While email is something you always have and can use to build claims login, with the principal id it’s not that simple.
What’s SharePoint principal id
Principal id is an id assigned to a user on a specific SharePoint site. It’s not a fixed guid, as the user id in Entra AD, but it varies between sites. Once the user visits a site, or you use him anywhere on the site, he’ll receive the id. That means one user can have a different principal id on each SharePoint site in your organisation.
This id is then used when managing permissions via http requests, or when creating items in a SharePoint list, let it be a single item or a batch import.
How to assign the principal id
As you can see above, you need an http request to get this id. Yet there’s no id to get if the users doesn’t have one on the site. Trying to get id of such user will stuck the flow.
Therefore, if you’re not sure whether the user exists, it might be a good idea to do some preparations. By that I mean adding another http request to create this id (if it doesn’t exist yet).
Method: POST
Uri: _api/web/ensureUser
Header:
{
"accept": "application/json;odata=verbose",
"content-type": "application/json;odata=verbose"
}
Body:
{
"logonName": "<user email address>"
}
Note: <…> is a placeholder, replace it including the < and >.
After this request you can be sure that the user has a principal id. Get it and use wherever you need.
Summary
You probably won’t need the user principal id very often, but if you’re using a lot of http requests to SharePoint in your Power Automate flows, it’s good to know they exist. It’s a special user id, a different number on each SP site, assigned only when needed. Which can be a problem if your flow is the first one who needs that. Yet as many times before, if you’re not sure, there’s an http request to help you deal with these situations.