How to use waitfor response method in servicenow rest call?

Manikantahere
Tera Contributor

I am seeing default servicenow http time out is 30 seconds can we increase based on integration?

 

WaitforResponse() can be used in both synchronous and asynchronous calls? is it can be used without turning off the property glide.http.outbound.max_timeout??

 

9 REPLIES 9

Bhimashankar H
Mega Sage

hi @Manikantahere ,

 

Yes, you can increase the timeout. 

  • If 'glide.http.outbound.max_timeout.enabled' is set to true, the timeout is capped at the property value (default 30s).

  • To set a timeout longer than 30s (for specific integrations), you must set glide.http.outbound.max_timeout.enabled to false. Then, use waitForResponse(milliseconds) in your script to specify a longer timeout.

waitForResponse() is designed for asynchronous outbound REST/SOAP calls issued via executeAsync(), not for synchronous calls. After making an asynchronous call, you can call waitForResponse(timeout) on the response object to block the script and wait for the outcome, up to the timeout you define (in milliseconds). For synchronous REST/SOAP calls (using .execute()), the timeout behavior is determined strictly by the system property, and waitForResponse() is not applicable. 

 

¹If glide.http.outbound.max_timeout.enabled is set to false and you don't specify waitForResponse(), the system will use a default of 5 minutes for async calls. 

 

Thanks,
Bhimashankar H

 

-------------------------------------------------------------------------------------------------
If my response points you in the right directions, please consider marking it as 'Helpful' & 'Correct' Thanks!

 

SumanthDosapati
Mega Sage
Mega Sage

@Manikantahere 

  1. I am seeing default servicenow http time out is 30 seconds can we increase based on integration? - YES
  2. WaitforResponse() can be used in both synchronous and asynchronous calls? - NO 
  3. can be used without turning off the property glide.http.outbound.max_timeout?? - NO

 

Accept the solution and mark as helpful if it does, to benefit future readers.
Regards,
Sumanth

 

 

May I know how to increase timeout as per integration with out effecting other integrations within the sync rest call? 

Ankur Bawiskar
Tera Patron
Tera Patron

@Manikantahere 

for sync it's strict -> 30 seconds and cannot exceed regardless of you use waitForResponse()

for async you can call waitForResponse() after executeAsync()

If glide.http.outbound.max_timeout.enabled is false, the timeout you supply to waitForResponse() will be honored (up to 5 minutes by default, or longer if properties are adjusted). If this property is true, the smallest value between the waitForResponse() argument and glide.http.outbound.max_timeout will be used

Workaround:

To set a longer timeout in integrations

-> turn glide.http.outbound.max_timeout.enabled to false

-> use asynchronous execution with waitForResponse() in your script.

If my response helped please mark it correct and close the thread so that it benefits future readers.

Regards,
Ankur
Certified Technical Architect  ||  9x ServiceNow MVP  ||  ServiceNow Community Leader