Legacy Dev Forum Posts

 View Only

Sign Up

Exception when calling UsersApi#getUser

  • 1.  Exception when calling UsersApi#getUser

    Posted 06-05-2025 18:24

    Burak_Istanbullu | 2022-12-08 14:01:56 UTC | #1

    Hello team,

    I am trying to get a user detail, I am able to connect to Genesys cloud but getting the user part gives the following error;

    Exception when calling UsersApi#getUser com.mypurecloud.sdk.v2.ApiException: error at com.mypurecloud.sdk.v2.ApiClient.interpretConnectorResponse(ApiClient.java:705) at com.mypurecloud.sdk.v2.ApiClient.getAPIResponse(ApiClient.java:757) at com.mypurecloud.sdk.v2.ApiClient.invoke(ApiClient.java:868) at com.mypurecloud.sdk.v2.api.UsersApi.getUser(UsersApi.java:1744) at com.mypurecloud.sdk.v2.api.UsersApi.getUser(UsersApi.java:1704) at FirstClass.main(FirstClass.java:52)

    You can see my Java code here;

    importjava.io.IOException; importjava.util.Arrays; importjava.util.List;

    importcom.mypurecloud.sdk.v2.ApiClient; importcom.mypurecloud.sdk.v2.ApiException; importcom.mypurecloud.sdk.v2.ApiResponse; importcom.mypurecloud.sdk.v2.Configuration; importcom.mypurecloud.sdk.v2.api.UsersApi; importcom.mypurecloud.sdk.v2.extensions.AuthResponse; importcom.mypurecloud.sdk.v2.model.User; importcom.mypurecloud.sdk.v2.model.UserMe; importcom.mypurecloud.sdk.v2.PureCloudRegionHosts; importcom.mypurecloud.sdk.v2.model.ErrorBody;

    public class FirstClass {

    public static void main(String[] args)

    {

    String clientId = "xxx"; String clientSecret = "xxx";

    //Set Region PureCloudRegionHosts region = PureCloudRegionHosts.uswest2;

    ApiClient apiClient = ApiClient.Builder.standard().withBasePath(region).build(); ApiResponse<AuthResponse> authResponse; try { authResponse = apiClient.authorizeClientCredentials(clientId, clientSecret); System.out.println(authResponse.getBody().toString());

    } catch (IOException e) { // TODOAuto-generated catch block e.printStackTrace(); } catch (ApiException e) { // TODOAuto-generated catch block e.printStackTrace(); }

    Configuration.setDefaultApiClient(apiClient);

    String state=""; // String

    Search for a user with this state

    String integrationPresenceSource = "integrationPresenceSource_example"; // String

    Gets an integration presence for a user instead of their default.

    List<String> expand = Arrays.asList(); // List<String>

    Which fields, if any, to expand

    String userId = "xxxx"; // String

    User ID

    UsersApi apiInstance = new UsersApi();

    try{ // Get user. User result = apiInstance.getUser(userId, expand, integrationPresenceSource, state); System.out.println(result);

    } catch (ApiException | IOException e) { System.err.println("Exception when calling UsersApi#getUser"); e.printStackTrace();

    } }}


    Burak_Istanbullu | 2022-12-13 17:40:32 UTC | #2

    Hello again,

    I found the issue and fixed that. You can see the fixed part of the code below;

    Before; User result = apiInstance.getUser(userId, expand, integrationPresenceSource, state);

    After; User result = apiInstance.getUser(userId, expand, null, state);

    Thank you.


    John_Carnell | 2022-12-19 15:16:43 UTC | #3


    This post was migrated from the old Developer Forum.

    ref: 17572