创建用户时出错{" odata.error":{" code":" Request_BadRequest"

时间:2015-07-22 14:03:51

标签: c# azure azure-active-directory adal

我正在尝试使用ADAL创建Azure Active Directory用户,我收到此错误:

$(function () {
    $("#dialog").dialog({
        autoOpen: false,
        modal: true,
        title: "WhateverPageTitleYouWant",
        buttons: {
            Close: function () {
                $(this).dialog('close');
            }
        }
    });
    $("#ElementKickingThingsOff").click(function () {
        $.ajax({
            type: "GET",
            url: "Test.aspx",
            success: function (pageContents) {
                $("#dialog").html(pageContents);
                $("#dialog").dialog("open");
            }
        });
    });
});

堆栈追踪:

{"odata.error":{"code":"Request_BadRequest","message":{"lang":"en","value":"Property  value is required but is empty or missing."},"values":null}}

我的代码主要是此示例中的复制粘贴:

https://github.com/AzureADSamples/WebApp-GraphAPI-DotNet/blob/master/WebAppGraphAPI/Views/Users/Create.cshtml

https://github.com/AzureADSamples/WebApp-GraphAPI-DotNet/blob/master/WebAppGraphAPI/Controllers/UsersController.cs

我尝试按代码设置语言:

   at System.Data.Services.Client.SaveResult.HandleResponse()
   at System.Data.Services.Client.BaseSaveResult.EndRequest()
   at System.Data.Services.Client.DataServiceContext.EndSaveChanges(IAsyncResult asyncResult)
   at System.Threading.Tasks.TaskFactory`1.FromAsyncCoreLogic(IAsyncResult iar, Func`2 endFunction, Action`1 endAction, Task`1 promise, Boolean requiresSynchronization)
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at Microsoft.Azure.ActiveDirectory.GraphClient.Extensions.DataServiceContextWrapper.<SaveChangesAsync>d__74.MoveNext()
--- End of stack trace from previous location where exception was thrown ---
   at System.Runtime.CompilerServices.TaskAwaiter.ThrowForNonSuccess(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)
   at System.Runtime.CompilerServices.TaskAwaiter.GetResult()
   at CapatechSaasApp.Areas.GlobalAdmin.UsuarioController.<Create>d__3.MoveNext() in C:\Proyectos\xx\xx\Areas\GlobalAdmin\Controllers\UsuarioController.cs:line 143

但是没有任何区别,错误并不能说明必须设置哪个属性。

1 个答案:

答案 0 :(得分:4)

经过几次尝试后,我注意到我错过了要设置的AccountEnabled属性,奇怪的是消息不够清楚,应该说明缺少哪个属性值