Graph API request returning "One or more properties contains invalid values"
Asked Answered
S

3

1

I am trying to execute B2C user creation on our company's Azure Directory. As reference, I use this site from Microsoft, and the .DotNet example in it.

https://azure.microsoft.com/en-us/documentation/articles/active-directory-b2c-devquickstarts-graph-dotnet/

I thoroughly follow the example, and I get to the point where I get authenticated, and I am able to extract the AD users in the directory. Here is the sample request I generated.

GET https ://graph.windows.net/mycompany/users?api-version=beta

But when I get to the part of creating a sample user in the directory, I get the error response "One or more properties contains invalid values".

POST https ://graph.windows.net/mycompany/users?api-version=beta

Here is the payload, I used, which is the exact same payload used in the site's example for user creation. This is in JSON format.

{"accountEnabled": true,"alternativeSignInNamesInfo": [{"type": "emailAddress", "value": "[email protected]"}],"creationType": "NameCoexistence", "displayName": "Joe Consumer", "mailNickname": "joec","passwordProfile": {"password": "P@ssword!","forceChangePasswordNextLogin": false},"passwordPolicies": "DisablePasswordExpiration"}

This payload conforms with the requirements based on the User Creation requirements from Microsoft, also, it is the exact same payload in the site's example, which is why it is strange that I am receiving the a message that one of the properties has invalid values. The worse thing is, the response does not explicitly state which value is the source of the problem.

Any help would be appreciated.

Slype answered 17/2, 2016 at 11:22 Comment(0)
V
1

I got this error when trying to create a user with a sign in name where the type was set to userName and the value was actually an email address. I thought username would allow any arbitrary string, but apparently if you want to use an email as a username the type must be set to emailAddress before it will pass Microsoft's validation.

public class SignInNames
{
    public string type { get; set; }
    public string value { get; set; }

    public SignInNames(string userName)
    {
        // Type must be 'emailAddress' (or 'userName')
        if (!string.IsNullOrWhiteSpace(userName) && userName.Contains("@"))
            this.type = "emailAddress";
        else
            this.type = "userName";

        // The user email address
        this.value = userName;
    }
}
Ventilation answered 12/7, 2018 at 17:23 Comment(0)
A
0

I don't think this is possible on your company's Active Directory, you need to create a seperate B2C Active Directory.

Follow this tutorial to create a B2C directory: https://azure.microsoft.com/en-us/documentation/articles/active-directory-b2c-get-started/

Anvers answered 18/2, 2016 at 13:49 Comment(2)
Thank you very much. I will try that and let you know how it goes.Slype
i tried both but when i make separate B2C Active Directory i get Error insufficient privilege to complete operation, when i try Application reg. step mentioned in question i get error "One or more properties contains invalid values." pls help me which one to follow.Galway
D
0

Do you have B2C tenant created and it has application that is created in Azure AD.

Can you please try this payload, it works fine for me.

{
  "accountEnabled": true,
  "signInNames": [
    {
      "type": "emailAddress",
      "value": "[email protected]"
    }
  ],
  "creationType": "LocalAccount",
  "displayName": "karthikeyan",
  "mailNickname": "karthikeyan",
  "passwordProfile": {
    "password": "cads2016!",
    "forceChangePasswordNextLogin": false
  },
  "passwordPolicies": "DisablePasswordExpiration",
  "city": "San Diego",
  "country": null,
  "facsimileTelephoneNumber": null,
  "givenName": "Joe",
  "mail": null,
  "mobile": null,
  "otherMails": [],
  "postalCode": "92130",
  "preferredLanguage": null,
  "state": "California",
  "streetAddress": null,
  "surname": "Consumer",
  "telephoneNumber": null,

}
Deponent answered 8/6, 2017 at 6:51 Comment(0)

© 2022 - 2024 — McMap. All rights reserved.