在图表API请求中返回“一个或多个属性包含无效值". [英] Graph API request returning "One or more properties contains invalid values"

查看:151
本文介绍了在图表API请求中返回“一个或多个属性包含无效值".的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试在我们公司的Azure目录上执行B2C用户创建.作为参考,我使用Microsoft的此站点以及其中的.DotNet示例.

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/

我完全按照示例进行操作,现在我明白了 身份验证,并且我能够提取目录中的AD用户.这是我生成的示例请求.

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.

获取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

这是我使用的有效负载,与网站示例中用于创建用户的有效负载完全相同.这是JSON格式.

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":"joeconsumer@gmail.com"}],"creationType":"NameCoexistence","displayName:" Joe Consumer," mailNickname:" joec," passwordProfile:{" password:" P @ ssword!," forceChangePasswordNextLogin:false}," passwordPolicies:" DisablePasswordExpiration}

此有效负载符合基于Microsoft的用户创建"要求的要求,而且,它与站点示例中的有效负载完全相同,这就是为什么我收到一条消息,其中一个属性具有无效的值.更糟糕的是,响应没有明确指出哪个值是问题的根源.

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.

任何帮助将不胜感激.

推荐答案

尝试创建具有登录名的用户时,出现错误,该用户的登录名类型设置为userName,而值实际上是电子邮件地址.我以为用户名可以允许任意字符串,但是显然,如果您想使用电子邮件作为用户名,则必须先将类型设置为emailAddress,然后才能通过Microsoft的验证.

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;
    }
}

这篇关于在图表API请求中返回“一个或多个属性包含无效值".的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆