APIException error

I am listening to Queue memebership events in a Flink application continuously and it's been 2 days. I started getting this error.

2021-07-30 07:57:10.933 [update-state -> flattener -> transform-to-output -> Sink: Unnamed (1/1)] ERROR c.u.c.i.faas.operator.salesforce.QueueAgentStateUpdater - com.mypurecloud.sdk.v2.ApiException: error

com.mypurecloud.sdk.v2.ApiException: error

at com.mypurecloud.sdk.v2.ApiClient.interpretConnectorResponse(ApiClient.java:706)

at com.mypurecloud.sdk.v2.ApiClient.getAPIResponse(ApiClient.java:758)

at com.mypurecloud.sdk.v2.ApiClient.invoke(ApiClient.java:869)

at com.mypurecloud.sdk.v2.api.RoutingApi.getRoutingQueueMembers(RoutingApi.java:2325)

at com.uber.co.insights.faas.common.source.PurecloudAPI.getQueueMembers(PurecloudAPI.java:102)

at com.uber.co.insights.faas.operator.salesforce.QueueAgentStateUpdater.synchronizeFlinkStateAndEmitDiffs(QueueAgentStateUpdater.java:88)

at com.uber.co.insights.faas.operator.salesforce.QueueAgentStateUpdater.consume(QueueAgentStateUpdater.java:63)

at com.uber.co.insights.faas.operator.salesforce.QueueAgentStateUpdater.consume(QueueAgentStateUpdater.java:23)

at com.uber.co.insights.faas.common.functions.CORichMapFunction.map(CORichMapFunction.java:20)

at org.apache.flink.streaming.api.operators.StreamMap.processElement(StreamMap.java:41)

at org.apache.flink.streaming.runtime.io.StreamOneInputProcessor.processElement(StreamOneInputProcessor.java:164)

at org.apache.flink.streaming.runtime.io.StreamOneInputProcessor.processInput(StreamOneInputProcessor.java:143)

at org.apache.flink.streaming.runtime.tasks.StreamTask.processInput(StreamTask.java:279)

at org.apache.flink.streaming.runtime.tasks.StreamTask.run(StreamTask.java:321)

at org.apache.flink.streaming.runtime.tasks.StreamTask.runAndHandleCancel(StreamTask.java:286)

at org.apache.flink.streaming.runtime.tasks.StreamTask.invoke(StreamTask.java:426)

at org.apache.flink.runtime.taskmanager.Task.doRun(Task.java:705)

at org.apache.flink.runtime.taskmanager.Task.run(Task.java:530)

at java.lang.Thread.run(Thread.java:748)

2

I know that credentials work, what might be reason ? Is my continuous listening a problem ?

Hi Raj,

It appears that you received an ApiException from the call to getRoutingQueueMembers, so that would indicate that continuous listening was not the problem.

The issue may be your auth token expiring. Auth tokens provided by Client Credential grants typically have a lifespan of 1 day. There is currently no automatic refreshing of tokens provided by Client Credential grants in the Java SDK so you would have to manually request a new token if you get a 401 response from the API.

Logging the getRawBody() and getCorrelationId() values of the ApiException are helpful for debugging when an error is encountered.

@anon11147534 I am authenticating using client Id and client secret not by token id. So it's not about the token expiry right ?

Hello,

When you authenticate with an OAuth Client Credentials Grant flow, you provide a ClientID and ClientSecret, and get an access token in return.
See this article on Client Credentials Grant flow for more information.

When you create your OAuth Client Credentials Grant client in the configuration (Admin UI), you specify a Token duration (in seconds - default value is set to 86400 seconds = 1 day).
This means that the access token you obtain via the authorizeClientCredentials method will be valid for 24 hours. When the token expires, you will get an HTTP 401 status back when you make a request to a Platform API endpoint. In this case, you just need to obtain a new token, calling the authorizeClientCredentials method again.

Regards,

This topic was automatically closed 31 days after the last reply. New replies are no longer allowed.