I use WithHttpInfo. 504 error caught as exception

Good day. Your support please.

I am using the Analytics APIs with the .Net SDK and want to catch error codes. Because I am continually getting 504 API timeout errors.

ApiResponse<AnalyticsConversationAsyncQueryResponse> resultConversationsNext = instanceAnalyticsApiJob.GetAnalyticsConversationsDetailsJobResultsWithHttpInfo(sJobId, sCursor, 1000);
                                        
if (resultConversationsNext.StatusCode == 504)

The API that I am using is the conversation detail Job, to obtain the results according to the jobId that I previously generated.
Up to a certain point I have satisfactory results (code 200), there comes a time when it returns a 504 code but instead sends it as an exception, instead of being able to detect it in the object and be able to deal with that type of error.

I appreciate your support and if any other information is missing, let me know.
Greetings.

Hi Julio,

I checked the source code from our .NET API. Basically, any error code over 400 is thrown as an API exception. You can see that here. While I agree with you that this does not make sense (if you are requesting the HttpInfo, the developer should be responsible for checking the status codes and dealing with the errors). I am going to chat with my Senior Engineer in the SDK space. The one problem we are going to have is that this SDK has been out here for a while and changing the behavior could be a pretty big breaking change.

For now, I would assume that you are going to have to catch an ApiException and that while the HttpInfo can provide various information (e.g. response headers), it will not be very useful for reading the error code.

Thanks,
John Carnell
Manager, Developer Engagement

Hello Juan.

Thanks for your answer. I understand that the .Net SDK is not supporting avoiding exceptions for error codes greater than 400.
Please help me with the following. API error code retries could be addressed as follows?:

var retryConfig = new ApiClient.RetryConfiguration
            {
                MaxRetryTimeSec = 10,
                RetryMax = 20
            };

 Configuration.Default.ApiClient.RetryConfig = retryConfig;

Thanks for your support.

Greetings.
Julio Segil

You can configure the retry timing per the documentation here: https://developer.genesys.cloud/api/rest/client-libraries/dotnet/#setting-the-max-retry-time. It only retries on the documented retryable error codes.

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