Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

One or more properties contains invalid values in Microsoft graph API

Tags:

I want to create users on the Azure Active Directory B2C i followed each steps for that in the given link Here

URL :- https://graph.windows.net/testinggmail.onmicrosoft.com/users?api-version=1.6

Type :- POST

Header :-

 Authorization:Bearer eyJ0eXAiOiJKV1QiLCJhbGciOiJSUzI1NiIsIng1dCI6IlNTUWRoSTFjS3ZoUUVEU0p4RTJnR1lzNDBRMCIsImtpZCI6IlNTUWRoSTFjS3ZoUUVEU0p4RTJI6Imh0dHBzOi8vc3RzLndpbmRvd3MubmV0LzBkZjk3YTliLTQ3MDAtNDY5NS05ZjUyLWNkYzJiYzljMTk2Ny8iLCJpYXQiOjE1MjA4Mzg4OTAsIm5iZiI6MTUyMDgzODg5MCwiZXhwIjoxNTIwODQyNzkwLCJhaW8iOiJZMk5nWU9pNFg3NXh3NGJGcTNYMnFaMmVkZW44T1FBPSIsImFwcGlkIjoiYjc2MDFmOTktYjFiZS00YWQ0LTljMmMtYTVlNzBiYmZkNWNhIiwiYXBwaWRhY3IiOiIxIiwiZV9leHAiOjI2MjgwMCwiaWRwIjoiaHR0cHM6Ly9zdHMud2luZG93cy5uZXQvMGRmOTdhOWItNDcwMC00Njk1LTlmNTItY2RjMmJjOWMxOTY3LyIsIm9pZCI6IjhlNTQwMmViLTRkNTMtNDc5Ny1iOWRjLWFlOGJmMzRmMTE4MCIsInJvbGVzIjpbIkRldmljZS5SZWFkV3JpdGUuQWxsIiwiRGlyZWN0b3J5LlJlYWQuQWxsIiwiTWVtYmVyLlJlYWQuSGlkZGVuIiwiRGlyZWN0b3J5LlJlYWRXcml0ZS5BbGwiLCJEb21haW4uUmVhZFdyaXRlLkFsbCIsIkFwcGxpY2F0aW9uLlJlYWRXcml0ZS5Pd25lZEJ5IiwiQXBwbGljYXRpb24uUmVhZFdyaXRlLkFsbCJdLCJzdWIiOiI4ZTU0MDJlYi00ZDUzLTQ3OTctYjlkYy1hZThiZjM0ZjExODAiLCJ0ZW5hbnRfcmVnaW9uX3Njb3BlIjoiQVMiLCJ0aWQiOiIwZGY5N2E5Yi00NzAwLTQ2OTUtOWY1Mi1jZGMyYmM5YzE5NjciLCJ1dGkiOiJTYVU5Y3psb3kweW51NnNueUhVUkFBIiwidmVyIjoiMS4wIn0.YQf6dWra1jua8XMHdqqqd5vrpVUxil_6YMM00drLl9LmOchUY7AtPOXF6T_p7Bmf2BwOWL02bsm7VJCM5cx_TD0cMzbOr4uybmyJJvDqfi1whvgOWbDnY_J9ArJWQMuk7jPIBPS_WT8UYsmM_ivRmcQcRxZtcYCrAaWWOJFeWFVucJFz9G-ld0qi4TU10-Qk9_owREDoitlwYEZwEzSUU-HauDCkjNVzDNhefXrjlJHMzXcsJMnVyX7txkZpiqcsM8H-2EKbFmavT4fN05zUh1Hy6hSLnKv24uDyB3hf2qEZvOaygDUPFRcbFSWH39yp698FGh9Ayr8vHr9wLRHHdA
Content-Type:application/json

Request Body :-

 { 

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

Response :-

{
    "odata.error": {
        "code": "Request_BadRequest",
        "message": {
            "lang": "en",
            "value": "One or more properties contains invalid values."
        },
        "date": "2018-03-12T07:24:13",
        "requestId": "fef2037f-8c6f-4190-8c5a-727dcccde5eb",
        "values": null
    }
}'

Some API'S are working fine like GetUsers and TokenAcuire but not create user i have googled it also got many solution but didn't worked for me link is here what else i have tried Here if i follow that steps for creating separate Direcotry then i get Error Insufficient Privilege to Complete Operation.

like image 669
Amit Yadav Avatar asked Mar 12 '18 07:03

Amit Yadav


1 Answers

This type of user creation with the Azure AD Graph API is for Azure AD B2C:

Beginning with version 1.6, Graph API supports creating local and social account users for Azure Active Directory B2C tenants.

If you try to use this Azure AD Graph API request for a normal Azure AD tenant, it will get the same error massage as yours.

So, ensure the tenant you're trying to query is a B2C tenant:

Try to use the global admin of the B2C tenant (e.g. [email protected]) to obtain a token. Then use the token in the head to use the API :

Request:

 POST https://graph.windows.net/myorganization/users?api-version=1.6

Body Content-Type: application/json:

{ 

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

Hope this helps!

like image 197
Wayne Yang Avatar answered Nov 15 '22 03:11

Wayne Yang