-
Notifications
You must be signed in to change notification settings - Fork 37
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Unable to create new user #47
Comments
Hey @m-moris , I don't think you need to set the user id, it'll be automatically generated by the service upon creation. Lastly, you don't need to set the content type manually, the SDK does that for you. client := msgraphsdk.NewGraphServiceClient(adapter)
user := graph.NewUser()
user.SetDisplayName(ref("Shohei Ohtani"))
user.SetCreationType(ref("LocalAccount"))
// user.SetIdentities()... depends on your scenario
d := &u.UsersRequestBuilderPostOptions{
Body: user,
}
result, err := client.Users().Post(d)
if err != nil {
fmt.Printf("Error create new user %v\n", err)
return
}
spew.Dump(result) Let me know if you have further questions, if the questions are about how the identities property work, the best thing to do is to reach out on the Microsoft Q&A forum so you get the exact API call payload that the service expects for your scenario, and then revert here so we can "translate" this into Go code. |
Hi @baywet Let me give you my background. I am rewriting a program that used to create users by directly calling the REST API into a program that uses the SDK. The first sample I presented was wrong. The following is a sample that was able to create a user. However, I believe there are some problems. One is that The other is that setting the User structure always requires a pointer. It's hard to use boolean, String, etc. when pointers are always required, are there any plans to improve this?
Thanks. |
Add the problem mentioned earlier. Even if the user is created correctly, the Result object does not appear to have any value set. For example, when I call |
It may be the default behavior for |
Thanks for clarifying. Errors not being returned when the service returns a errorWe have a known limitation on deserializing and returning errors, we're planning to address this by GA. Pointers everywhereWhen serializing/deserializing the SDK needs to be able to convey the difference of information between "the value is set to the default" and "the value is not set".
And the same challenge arises the other way around, the SDK user needs to be able to tell the difference between the service didn't return anything for this property and the service returned a default value.
Now what we could do to make people's lives easier is provide a bunch of functions like "RefString" "RefBoolean" accepting a scalar value as argument (no pointer) and returning a pointer to it. This way people wouldn't have to create a variable and reference it. MailNickName property is nilI'm not sure what's the behavior of the service here, using a REST call, do you always get a value on the POST call for that property? It might be that value is not populated (stored in the data store), or not returned by default. |
Hi @baywet about pointerI am just starting to use the Go language, so I don't have any idea about the desired specification. I agree with you that this is a feature that should be provided by the compiler. response valueI was mistaken because some properties do not return a value by default. DisplayName is correctly included in the response. Thanks a lot of support. I'm looing forward GA! |
Thanks for all the feedback you've provided so far. I think all the discussions on this thread are resolved. Closing |
I'm trying to create new user in Azure AD B2C with the following program, but I cannot create it.
The
err
is null, so it is not determined to be a direct error, but when I dump theresult
object, the error message is embedded. Is the program wrong? How can I create the correct user?Thank
The text was updated successfully, but these errors were encountered: