‘The user does not exist or is not unique’ error in Power Automate

In this Power Automate tutorial, we will see how we can fix the error ‘The user does not exist or is not unique’ in Power Automate.

Recently, when we were trying to add members to an existing Communication site using Power Automate, we came across an error. This error states that the user does not exist or is not unique in Power Automate.

You can see the screenshot below:

Microsoft Power Automate error 'The user does not exist or is not unique'
Microsoft Power Automate error ‘The user does not exist or is not unique’

So, in this Power Automate tutorial, we will discuss the solution of how the solve the error when the user does not exist or is not unique.

The user does not exist or is not unique error in Power Automate

Here, we were having an existing communication site in SharePoint named “HR Hub“. Now, we were using Power Automate to add members to this existing SharePoint site.

For the execution of this task in Power Automate, we first need to fetch the member group id of the communication site.

Once we get the group id, we will then parse the JSON output that will reflect in the dynamic content. After this, we will use the member group id to add members to this particular site.

Here are the steps that we followed in Power Automate:

Step-1: Click on +New step and select ‘Send an HTTP request to SharePoint‘. Next, add the below information:

  • Site address: Select the site URL from the dynamic content
  • Method: Select the GET method, because we are fetching the group id from the site
  • Uri: Provide the “_api/web?$select=AssociatedMemberGroup/Id&$expand=AssociatedMemberGroup” , to get the group id
  • Headers: Provide the headers like the ones below, which are required to do the rest API calls.
{
  "Accept": "application/json;odata=nometadata"
}

Step-2: Again, click on +New step and select Parse json action, then provide the below information:

  • Content: Select the Body from the dynamic content, from the previous step.
  • Schema: To get the schema, click on ‘Generate from sample‘, and then provide the json code of the output of the above step.
{
  "AssociatedMemberGroup": {
    "Id": 5
  }
}

Step-3: This is the main step where we will add members to the SharePoint site. So click on the +New step and then select Send an HTTP request to SharePoint action. After this, add the following data:

  • Site address: Select the Site URL from the dynamic content.
  • Method: Select the POST method, as we are adding members to the SharePoint site.
  • Uri: Provide the API as ‘/api/web/sitegroups/getById(@{body(‘Parse_JSON-_Group_Id_3′)?[‘AssociatedMemberGroup’]?[‘Id’]})/users’ , to add the members to the SharePoint site.
  • Headers: Provide the headers like below, to do the rest API call we need Accept and content-type.
{
  "accept": "application/json;odata=verbose",
  "content-type": "application/json;odata=verbose"
}
  • Body: In the body, provide the below json code to add a member to the SharePoint site.
{
    "__metadata": {
        "type": "SP.User"
    },
    "LoginName": "<provide the member email>"
}
'The user does not exist or is not unique' error in Power Automate
‘The user does not exist or is not unique’ error in Power Automate

However, when we were running this flow, we came across this error- ‘The user does not exist or is not unique‘ error in Power Automate. You can also refer to the image given below for a detailed error message.

Microsoft Power Automate error 'The user does not exist or is not unique'
Microsoft Power Automate error ‘The user does not exist or is not unique’

Now, in the next section, we will see how to resolve this error in Poer Automate.

See also  How to Convert XML to string in Power Automate?

‘The user does not exist or is not unique’ error in Power Automate – Solution

Here first let us understand why we face this error ‘The user does not exist or is not unique’ in Power Automate.

Now, if you look closely at Step-3 we specified ‘LoginName’ in the previous section, we specified the Body as the following:

{
    "__metadata": {
        "type": "SP.User"
    },
    "LoginName": "<provide the member email>"
}

Here for this LoginName, we directly specified the member email id. However, this method in Power Automate is not correct. Instead, we need to specify the LoginName field as given below.

{
    "__metadata": {
        "type": "SP.User"
    },
    "LoginName": "i:0#.f|membership|<provide the member email>"
}

So, before mentioning the member’s email address, we also need to specify i:0#.f|membership|. This string before the email address is used to indicate the login name in SharePoint. Which is used for user authentication.

Power Automate error 'The user does not exist or is not unique'
Power Automate error ‘The user does not exist or is not unique’

This is how we can fix the error ‘The user does not exist or is not unique’

Conclusion

In this Power Automate tutorial, we saw how we fix the error ‘The user does not exist or is not unique’ in Power Automate.

You may also like:

>