gpt4 book ai didi

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

转载 作者:行者123 更新时间:2023-11-30 20:42:12 25 4
gpt4 key购买 nike

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

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

堆栈跟踪:

   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

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

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

我尝试通过代码设置语言:

user.PreferredLanguage= "en"

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

最佳答案

经过几次尝试,我发现我缺少要设置的 AccountEnabled 属性,奇怪的是消息不够清晰,它应该说缺少哪个属性值

关于c# - 创建用户时出错 {"odata.error": {"code" :"Request_BadRequest",我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/31565446/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com