Try-Catch not working for HTTP call

Hi UIPath Gurus,

I have a process to call HTTP REST service, and I have kept this HTTP Request inside Try, and in catch I am using System.Exception, along with a Message Box like “Inside catch”.
To test this schenario, I have purposefully given incorrect URL for the REST service, the catch is never getting executed, not sure what is the issue.

Can you guys advice.


1 Like

The HTTP Request activity doesn’t throw an exception if the result of the request itself is not success.
Instead, it returns a code via the StatusCode property, which you need to check (for example, using an If activity) if it is the code you were expecting to have (for example, 200). If it is not, you can throw an exception using the Throw activity.

Also note that, in older versions of the activity, it would return 0 as StatusCode instead of throwing an exception if it timed out.
However, in more recent versions, it will throw an exception in the case of timeout.

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