question

ZahmiZuhair-5110 avatar image
0 Votes"
ZahmiZuhair-5110 asked saldana-msft edited

Cannot create a azure b2c user via MS Graph API

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://docs.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

azure-ad-b2cmicrosoft-graph-users
image.png (76.3 KiB)
image.png (305.2 KiB)
· 1
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

Is the tenant id in your code Azure ad b2c tenant id?

0 Votes 0 ·
ZahmiZuhair-5110 avatar image
0 Votes"
ZahmiZuhair-5110 answered

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 :)


image.png (33.2 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

CarlZhao-MSFT avatar image
0 Votes"
CarlZhao-MSFT answered CarlZhao-MSFT edited

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://docs.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.





267.png (25.6 KiB)
266.png (60.6 KiB)
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

ZahmiZuhair-5110 avatar image
0 Votes"
ZahmiZuhair-5110 answered ZahmiZuhair-5110 commented

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



image.png (20.7 KiB)
image.png (43.8 KiB)
· 11
5 |1600 characters needed characters left characters exceeded

Up to 10 attachments (including images) can be used with a maximum of 3.0 MiB each and 30.0 MiB total.

I think it may be the reason for the code, can you use Graph Explorer to create b2c users?

0 Votes 0 ·

Hi @CarlZhao-MSFT

I tried the Graph Explorer, But I get the following error.


122233-image.png

Appreciate your help in resolving this matter.

Thanks,
Zahmi


0 Votes 0 ·
image.png (76.5 KiB)

@ZahmiZuhair-5110 I have found your question and revised my answer, please see my answer update :)

0 Votes 0 ·
Show more comments