cancel
Showing results for 
Search instead for 
Did you mean: 
Read only

ABAP Environment in BTP: Handling API Timeout for Long-Running Requests

reda_hamrani
Explorer
1,174

Hello SAP Community,

I have developed an ABAP program in the ABAP Environment on SAP BTP that calls an external API. The request works fine when the response time is short, but when the request takes longer, I get a timeout error:

"The operation was timeout."

I would like to know:

  1. Is it possible to increase the timeout duration for HTTP requests in the ABAP Environment on BTP?
  2. If so, how can I configure it properly?
  3. Are there alternative solutions to handle long-running API requests in ABAP?

Here is a simplified version of my HTTP request implementation:

 

 

   DATA(lo_destination) = cl_http_destination_provider=>create_by_url( c_api_endpoint ).
  DATA(lo_client) = cl_web_http_client_manager=>create_by_http_destination( lo_destination ).
....
DATA(lo_response) = lo_client->execute( i_method = if_web_http_client=>post ).

 

 

Any guidance or best practices would be greatly appreciated.

Thanks in advance!

SAP BTP ABAP environment  API  

Accepted Solutions (1)

Accepted Solutions (1)

Dinu
Active Contributor

There is a second parameter to lo_client->execute for setting timeout. 

lo_client->execute( i_timeout = 10 ...

Note: timeout is in seconds, this is only the timeout for the initial delay; -1 is for infinite timeout, this is not recommended. 

reda_hamrani
Explorer
0 Kudos
I still have the issue even with `i_timeout = -1`. Are there any other parameters I need to adjust?
Dinu
Active Contributor
Is the method execute raising an exception? If not, you may be getting the response from an intermediary or the resource server itself.
reda_hamrani
Explorer
0 Kudos
Thanks, Dinu, for your guidance and suggestions. I discovered that the server has a time limit of 120 seconds.

Answers (1)

Answers (1)

Ulrich_Schmidt1
Product and Topic Expert
Product and Topic Expert
0 Kudos

As you are using a destination (cl_web_http_client_manager=>create_by_http_destination( lo_destination )), you can also specify a timeout in the destination: go to transaction SM59, open the destination used here and then modify the timeout on the "Special Options" tab.

Sandra_Rossi
Active Contributor
0 Kudos
No SM59 in BTP.