Genesys Multicloud

 View Only
Discussion Thread View
  • 1.  Unable to initialize the workspace object from java api.

    Posted 05-06-2021 13:43
    Edited by Matt Lawson 09-13-2022 10:05

    Hello all,
    We are trying to create a custom softphone using workspace client java api. We are successfully received authorization OAuth bearer token. When we try to initiate the workspace object we are receiving following error

    com.genesys.workspace.common.WorkspaceApiException: initialize failed.
    ...

    Caused by: com.genesys.internal.common.ApiException: java.net.SocketTimeoutException: Read timed out
     at com.genesys.internal.common.ApiClient.execute(ApiClient.java:844)
     at com.genesys.internal.workspace.api.SessionApi.initializeWorkspaceWithHttpInfo(SessionApi.java:764)
     at com.genesys.workspace.WorkspaceApi.initialize(WorkspaceApi.java:298).

    import com.genesys.workspace.WorkspaceApi;
    import com.genesys.workspace.models.User;
    
    public class Main {
        public static void main(String[] args) throws Exception {
    try
    {
            String apiKey = "<apiKey>";
            String apiUrl = "<apiUrl>";
            
            //region Create an instance of WorkspaceApi
            //First we need to create a new instance of the WorkspaceApi class with the following parameters: **apiKey** (required to submit API requests) and **apiUrl** (base URL that provides access to the PureEngage Cloud APIs). You can get the values for both of these parameters from your PureEngage Cloud representative.
            WorkspaceApi api = new WorkspaceApi(apiKey, apiUrl);
            //endregion
    
            //region Authorization code grant
            //You'll need to use the Authentication API to get an authorization token. See https://github.com/GenesysPureEngage/authorization-code-grant-sample-app for an example of how to do this.
            String authorizationToken = "<authorizationToken1>";
            //endregion
            
            //region Initialization
            //Initialize the Workspace API with the authorization token from the previous step. This returns the current user, which we then print.
            User user = api.initialize(authorizationToken);
            System.out.println("The workspace api is now successfully initialized");
            System.out.println("User data: " + user); 
            //endregion
    
            api.destroy();
    }
    catch(Exception ex)
    {
    }
       }
    }




    #ArchitectureandDesign
    #AskaCustomer
    #DigitalChannels
    #Implementation
    #Integrations
    #Omni-ChannelDesktop/UserInterface
    #Outbound(CXContact)
    #Platform/SystemAdministration
    #QualityManagement
    #Reporting/Analytics
    #Roadmap/NewFeatures
    #RoutingandOrchestration
    #SecurityandCompliance
    #SIP/VolP
    #System Administration
    #Telephony
    #Unsure/Other

    ------------------------------
    Vinoth Ezhilan Manian
    Pointel (formerly Touch Point)
    ------------------------------


  • 2.  RE: Unable to initialize the workspace object from java api.

    GENESYS
    Posted 05-07-2021 11:16
    Vinoth,

    The Workspace API requires the OAuth bearer token to initialize.  You mentioned you were using a JWT and that is not the right token to use for this API.  How did you obtain the JWT?

    -Jim

    ------------------------------
    Jim Crespino
    Senior Director, Developer Evangelism
    Genesys
    https://developer.genesys.com
    ------------------------------



  • 3.  RE: Unable to initialize the workspace object from java api.

    Posted 05-07-2021 11:25
    My Bad, Its OAuth bearer token, used JWT instead of OAuth. Thanks for pointing out

    ------------------------------
    Vinoth Ezhilan Manian
    Pointel (formerly Touch Point)
    ------------------------------



  • 4.  RE: Unable to initialize the workspace object from java api.

    Posted 05-10-2021 03:36
    Edited by Matt Lawson 09-13-2022 10:05
    We can able to initiate the workspace object through cURL. but we need in java api, an help?.

    ------------------------------
    Vinoth Ezhilan Manian
    Pointel (formerly Touch Point)
    ------------------------------



  • 5.  RE: Unable to initialize the workspace object from java api.

    GENESYS
    Posted 05-10-2021 15:56
    Vinoth,

    Can you use a tool like Fiddler (https://www.telerik.com/fiddler) or Wireshark to capture what you are sending in both cURL and the Java application to compare the HTTP headers and the payloads?  There must be something not getting sent properly with the request in the Java app.

    ------------------------------
    Jim Crespino
    Senior Director, Developer Evangelism
    Genesys
    https://developer.genesys.com
    ------------------------------



Need Help finding something?

Check out the Genesys Knowledge Network - your all-in-one access point for Genesys resources