okta-sdk-java: Cannot update profile with array properties returned by user API
Describe the bug?
The profile object returned by the user API does not work with UpdateUserRequest. This code fails when the profile has custom array properties.
UserApi userApi = new UserApi(client);
var user = userApi.getUser(userId);
UserProfile profile = user.getProfile();
UpdateUserRequest request = new UpdateUserRequest().profile(profile);
userApi.replaceUser(userId, request, null);
What is expected to happen?
The userApi.replaceUser(userId, request, null); call should execute succesfully.
What is the actual behavior?
com.okta.sdk.error.ResourceException: HTTP 400, Okta E0000001 (Api validation failed: userProfile - '3 causes'), ErrorId <error-id>
at com.okta.sdk.error.ErrorHandler.handleError(ErrorHandler.java:114)
at org.springframework.web.client.ResponseErrorHandler.handleError(ResponseErrorHandler.java:63)
at org.springframework.web.client.RestTemplate.handleResponse(RestTemplate.java:825)
at org.springframework.web.client.RestTemplate.doExecute(RestTemplate.java:783)
at org.springframework.web.client.RestTemplate.exchange(RestTemplate.java:676)
at org.openapitools.client.ApiClient.lambda$invokeAPI$3(ApiClient.java:750)
at org.springframework.retry.support.RetryTemplate.doExecute(RetryTemplate.java:329)
at org.springframework.retry.support.RetryTemplate.execute(RetryTemplate.java:209)
at org.openapitools.client.ApiClient.invokeAPI(ApiClient.java:750)
at org.openapitools.client.api.UserApi.replaceUserWithHttpInfo(UserApi.java:3613)
at org.openapitools.client.api.UserApi.replaceUser(UserApi.java:3535)
...
The http response contains these details:
{"errorCode":"E0000001","errorSummary":"Api validation failed: userProfile","errorLink":"E0000001","errorId":"<error-id>","errorCauses":[{"errorSummary":"Invalid value data type for property '<array property>'"},{"errorSummary":"Invalid value data type for property '<array property>'"},{"errorSummary":"Invalid value data type for property '<array property>'"}]}
Reproduction Steps?
UserApi userApi = new UserApi(client);
var user = userApi.getUser(userId);
UserProfile profile = user.getProfile();
UpdateUserRequest request = new UpdateUserRequest().profile(profile);
userApi.replaceUser(userId, request, null);
Additional Information?
Doing this update using the REST API directly works.
It is unclear how array properties are supported by the API. Should the value of the additional property be a java.util.List of values or a string matching the format expected in the raw REST API?
Java Version
openjdk version “20” 2023-03-21 OpenJDK Runtime Environment Homebrew (build 20) OpenJDK 64-Bit Server VM Homebrew (build 20, mixed mode, sharing)
SDK Version
10.2.2
OS version
Darwin <hostname> 22.4.0 Darwin Kernel Version 22.4.0: Mon Mar 6 21:00:17 PST 2023; root:xnu-8796.101.5~3/RELEASE_X86_64 x86_64
About this issue
- Original URL
- State: closed
- Created a year ago
- Comments: 17 (10 by maintainers)
I can confirm that this worked. Thanks for fixing this.
@arvindkrishnakumar-okta your example is almost there. Create the user as described in step 1. In step 2 do not update the array attribute but another attribute.
@arvindkrishnakumar-okta the example above can recreate the issue.
The user you are getting needs a profile with a custom attribute with the data type: string array.