-
Notifications
You must be signed in to change notification settings - Fork 10
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
Cannot update sponsors of user #1002
Comments
Hi @Doc94 A work-around using the SDK: User sponsor = new User();
sponsor.setId("");
graphClient.users().withUrl(
client.getRequestAdapter().getBaseUrl() + "users/{userId}/sponsors/$ref"
).post(sponsor); Let me know if this works |
i test that and give me an error.
i test this based in another methods (not the perfect code...) public void addSponsor(@NotNull String userId, @NotNull String sponsorId) {
Preconditions.checkArgument(true, "Group ID cannot be null");
com.microsoft.graph.beta.models.ReferenceCreate referenceCreate = new com.microsoft.graph.beta.models.ReferenceCreate();
referenceCreate.setOdataId("https://graph.microsoft.com/v1.0/users/" + sponsorId);
HashMap<String, Object> requestParameters = new HashMap<>();
requestParameters.put("baseurl", "https://graph.microsoft.com/beta");
requestParameters.put("user%2Did", userId);
RequestInformation requestInformation = new RequestInformation(HttpMethod.POST, "{+baseurl}/users/{user%2Did}/sponsors/$ref", requestParameters);
requestInformation.headers.tryAdd("Accept", "application/json");
requestInformation.setContentFromParsable(this.graphClient.getRequestAdapter(), "application/json", referenceCreate);
HashMap<String, ParsableFactory<? extends Parsable>> errorMapping = new HashMap();
errorMapping.put("XXX", ODataError::createFromDiscriminatorValue);
this.graphClient.getRequestAdapter().sendPrimitive(requestInformation, errorMapping, Void.class);
} and this works but pretty sure im make unnecesary things for that. |
Describe the bug
Im updating a user with new sponsors but in the update user throw an internal issue.
Expected behavior
Update the user with the sponsors provided
How to reproduce
Get a User class for existing user with sponsors, modify the sponsors list adding a new sponsors, set and update user.
SDK Version
6.13.0
Latest version known to work for scenario above?
No response
Known Workarounds
No response
Debug output
Click to expand log
```Exception in thread "main" com.microsoft.graph.beta.models.odataerrors.ODataError: The context URL 'https://graph.microsoft.com/beta/$metadata#users(sponsors())/$entity' is invalid.
at com.microsoft.graph.beta.models.odataerrors.ODataError.createFromDiscriminatorValue(ODataError.java:36)
at com.microsoft.kiota.serialization.JsonParseNode.getObjectValue(JsonParseNode.java:212)
at com.microsoft.kiota.http.OkHttpRequestAdapter.lambda$throwIfFailedResponse$0(OkHttpRequestAdapter.java:674)
at com.microsoft.kiota.ApiExceptionBuilder.(ApiExceptionBuilder.java:26)
at com.microsoft.kiota.http.OkHttpRequestAdapter.throwIfFailedResponse(OkHttpRequestAdapter.java:673)
at com.microsoft.kiota.http.OkHttpRequestAdapter.send(OkHttpRequestAdapter.java:281)
at com.microsoft.graph.beta.users.item.UserItemRequestBuilder.patch(UserItemRequestBuilder.java:1138)
at com.microsoft.graph.beta.users.item.UserItemRequestBuilder.patch(UserItemRequestBuilder.java:1122)
at xxx.MSEntraService.updateUser(MSEntraService.java:86)
at xxx.Main.main(Main.java:147)
The text was updated successfully, but these errors were encountered: