I'm trying to get FlowAggregation data using postAnalyticsFlowsAggregatesQuery() method,
but got an ApiException: error as below .
【Error Log】
Authentication successful. Access token expires in 86399 seconds
HANDLE YOUR AUTH TOKENS LIKE PASSWORDS
401
null
{X-Cache=Error from cloudfront, Strict-Transport-Security=max-age=600; includeSubDomains, Cache-Control=no-cache, no-store, must-revalidate, X-Amz-Cf-Pop=KIX50-P3, Connection=keep-alive, X-Amz-Cf-Id=c1wjgS8U8M8zVmKbK464YJTPsUpJHrwES_JB45DVtdLKA7H3Tmnb1w==, Content-Length=154, ININ-Correlation-Id=7c2e717f-9461-4e27-bd3f-ad2d50b33479, Date=Wed, 12 Oct 2022 00:53:27 GMT, Content-Type=application/json, Via=1.1 cb9f42f368829a4cc310e5102b139936.cloudfront.net (CloudFront)}
com.mypurecloud.sdk.v2.ApiException: error
at com.mypurecloud.sdk.v2.ApiClient.interpretConnectorResponse(ApiClient.java:704)
at com.mypurecloud.sdk.v2.ApiClient.getAPIResponse(ApiClient.java:756)
at com.mypurecloud.sdk.v2.ApiClient.invoke(ApiClient.java:867)
at com.mypurecloud.sdk.v2.api.FlowsApi.postAnalyticsFlowsAggregatesQuery(FlowsApi.java:80)
at com.mypurecloud.sdk.v2.api.FlowsApi.postAnalyticsFlowsAggregatesQuery(FlowsApi.java:49)
at csc.batch.main.reportdata.report.GetTokenAndGetFlowInfo.main(GetTokenAndGetFlowInfo.java:76)
【Application detail】
1.Using an clientId and clientSecret,I got a token code sucessfully through authorizeClientCredentials() method as below.
→ApiResponse authResponse = apiClient1.authorizeClientCredentials(clientId, clientSecret);
String token = authResponse.getBody().getAccess_token();→i can got an token code successfully and it expires in 86399 seconds.
2.Using the token code got from above ,I build a new apiClinet as below.
→ ApiClient apiClient =Builder.standard()
.withAccessToken(token)
.withBasePath("https://api.mypurecloud.com")
.build();
Configuration.setDefaultApiClient(apiClient);
3.Using the method below I tried to get FlowAggregation data from genesysCloud.
→ FlowsApi apiInstance = new FlowsApi();
FlowAggregationQuery flowBody= new FlowAggregationQuery();
flowBody.setInterval("2022-05-06T00:00:00.000Z/2022-05-06T12:00:00.000Z");
flowBody.setGranularity("");
flowBody.setTimeZone("");
flowBody.setGroupBy(null);
flowBody.setFilter(null);
flowBody.setMetrics(null);
flowBody.setFlattenMultivaluedDimensions(true);
flowBody.setViews(null);
flowBody.setAlternateTimeDimension(null);
FlowAggregateQueryResponse result = apiInstance.postAnalyticsFlowsAggregatesQuery(flowBody);
→I got a 401 StatusCode here.
【more information】
・java version "1.8.0_341"
・platform-client-v2-155.0.0.jar
・the website my appication based on:
→about acess token
https://developer.genesys.cloud/devapps/sdk/java
→about analytics data
https://developer.genesys.cloud/analyticsdatamanagement/analytics/analytics-apis
I've checked many similar questions upload on the Genesys Cloud Developer Forum,
but Still can't have my problem solved.
I'd apreciate it if you can help me find what I am doing wrong. Thank you!