Download file via HTTP request - check for error

I refer to the guide posted here:

I am using method 2 to download excel files from my server. it works as expected when download is successful.

However, if for whatever reason, if unsuccessful, the downloaded file would be in html format with the error for example,
<TITLEAccess Denied</TITLE

</HEAD <BODY <FONT face="Helvetica" <big<strong</big<BR </FONT <blockquote <TABLE border=0 cellPadding=1 width="80%" <TR<TD <FONT face="Helvetica" <bigAccess Denied (authentication_failed)</big <BR <BR </FONT </TD

how do I get UiPath to tell me its an error/throw an exception instead of just saving the server response as an excel file?

Hi @tzj,

before use HTTP Request activity use check the url is valid or not.
Refer the below post.



Thanks. I used an int for the status code property in the http request, and do an if else check, such that if status code != 200, it will delete the file, and if =200, continues with the rest of the program.