Cannot create a azure b2c user via MS Graph API

Zahmi Zuhair 141 Reputation points
2021-08-10T07:03:25.967+00:00

Hi,

I'm using Microsoft Graph API to add users in to Azure AD B2C tenant. I follow the example 2 of following link.

https://learn.microsoft.com/en-us/graph/api/user-post-users?view=graph-rest-1.0&tabs=http

I set all necessary parameters but API returns an error. Please see following screenshot for the error.

121902-image.png

Please see the following screenshot for the parameters I set for the API.

121873-image.png

FYI I have set all necessary permissions as well.

Your support to solve this issue is much appreciated. My client is waiting for me to finish this ASAP.

Thanks!
Zahmi

Microsoft Security Microsoft Entra Microsoft Entra External ID
Microsoft Security Microsoft Graph
{count} votes

Accepted answer
  1. Zahmi Zuhair 141 Reputation points
    2021-08-12T08:11:33.98+00:00

    Hi @CarlZhao-MSFT ,

    After researching for hours, finally I found the solution. I submitted as a json rather than using the method provided by PHP SDK. Working code is as follows.

    122701-image.png

    Thank you for your time anyways :)

    0 comments No comments

2 additional answers

Sort by: Most helpful
  1. CarlZhao-MSFT 46,371 Reputation points
    2021-08-10T10:06:21.353+00:00

    The /users endpoint you are currently using is to create a work account instead of inviting users. If you are inviting users, you should use the /invitations endpoint. https://learn.microsoft.com/en-us/graph/api/invitation-post?view=graph-rest-1.0&tabs=http


    If an Answer is helpful, please click "Accept Answer" and upvote it.

    0 comments No comments

  2. Zahmi Zuhair 141 Reputation points
    2021-08-10T15:15:45.737+00:00

    Thank you for your reply. However I'm using the correct domain name. You can refer the below image.

    122042-image.png

    I even set all the parameters according to the Microsoft Graph documentation for creating a user in Azure B2C. I'm not sure what I'm missing here.

    122005-image.png


Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.