2
votes

I am trying to create an Azure Active Directory User using ADAL and I get this error:

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

Stack trace:

   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

My code is mainly a copy paste from this sample:

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

I tried setting the language by code:

user.PreferredLanguage= "en"

but that didnt make any difference, the error doesn't say which property must be set.

1
shame on the -1, post a constructive criticismLuis Valencia

1 Answers

4
votes

After several tries I noticed I was missing the property AccountEnabled to be set, weird that the message is not clear enough, it should say which property value is missing