1
votes

I'm trying to make a POST request to Azure AD GraphAPI to create a user in my AD B2C tenant, but I'm getting the following error

"Error Calling the Graph API: 
{  
"odata.error": {"code": "Request_DataContractVersionMissing",
"message": {"lang": "en", 
"value": "The specified api-version is invalid. The value must exactly match a supported version"}
}

I do send the version, and based on the docs it is supported.

enter image description here

Version 1.6

This section lists the changes for Graph API version 1.6.

Graph API version 1.6 introduces the following feature changes:

Added support for Azure Active Directory B2C local account users. This involves new properties on the User entity and a new complex type SignInName to support local account sign-in to Azure Active Directory B2C tenants. For more information about Azure Active Directory B2C, see the Azure Active Directory B2C documentation.

[Edit] submitted json

{"accountEnabled":true,"signInNames":[{"type":"userName","value":"ausername"}],"creationType":"LocalAccount","displayName":"A display name","passwordProfile":{"password":"a password","forceChangePasswordNextLogin":true},"passwordPolicies":"policies","country":"MX","givenName":"Fstname","surename":"Lstname","department":"Dpt","jobTitle":"Title","mail":"[email protected]","otherMails":[],"preferredLanguage":"es-MX"}

Any clue on why I'm getting the error?

3
can you share the full json submitted? (obiviously changing passwords, etc.)spottedmahn
@spottedmahn I added the payload to the questionpollirrata
I tried submitting your json and I got Invalid value specified for property 'passwordPolicies' of resource 'User'.spottedmahn
I removed password policy and I got Property 'mail' is read-only and cannot be set.spottedmahn
I removed mail and I got One or more property values specified are invalid.spottedmahn

3 Answers

2
votes

There is something wrong with the api-version query parameter: Request_DataContractVersionMissing

Data contract version parameter is missing. Include api-version as a query parameter with all your requests.

Doesn't Work https://graph.windows.net/ebenefitsdev.onmicrosoft.com/users?api‐version=1.6

I get Request_DataContractVersionMissing error when submitting that.

Does Work https://graph.windows.net/ebenefitsdev.onmicrosoft.com/users?api-version=1.6

The difference is the hyphen char. One is the 'normal' one I typed on my keyboard. The other is from here.

I suspect it is a copy paste problem (I've experienced these in the past).

1
votes

I see one problem: signInNames not signInName

sample graph create user call

Documentation for user entity

enter image description here

0
votes

For future readers, I ran into this issue with 2.0 of graph.windows.net, but it was not the hyphen. It seems this error is also shown if the client ID you used to get a resource token for graph.windows.net is not correct.