Hi All, I'm downloading a PDF file from a rest API, when the input parameter "pdfID" that i'm sending to the API is a valid one the PDF downloads with no problem but when the "pdfID" is not valid or the file has not been created yet I'm getting an error message "This site can't be reached". Is it possible to catch this "error" instead of displaying the error page?

I'm getting this "error" because this client hasn't complete his information yet and i am trying to download a file that hasn't been created yet.

Hi Reynaldo,

Could you give more detail about the download process? I mean how you get the file from the API?
If you get binary output from API, I guess you can check file the binary size from the response.

Have you ever check what you get from API response? attributes, headers etc.

Ferhat Karatay wrote:

Hi Reynaldo,

Could you give more detail about the download process? I mean how you get the file from the API?
If you get binary output from API, I guess you can check file the binary size from the response.

Have you ever check what you get from API response? attributes, headers etc.


Actually i don't get any info from the API only i send the request and then the file is downloaded, why i want to say is that I'm using the "ExternalURL" block to get the file so actually I do not get any reponse :(

Hi Reynaldo Merino,

You can use below HTTP action to test weather the URL is accessible or not before downloading file.

If accessible then you can download the file, if not throw error from server action itself. 

GetRequestContent - for more info about the action you can check here

Let me know if your not getting what I mean,So that I'll give more detailed explanation.


Sravan

Hi Reynaldo,

There are several ways to download a file. That's the reason I need to know how do you try to download.
I think the external URL widget is not useful for your case.

Here is an example I built for you hope it helps.
1. Reference GetRequest_Submit action to your project from HttpRequestHandler
2. Make your request to the URL with that action
3. After the response of  GetRequest_Submit check the result of API

Test 1 - I'm making a request to download an example PDF File to correct URL



Test 2 - I'm making a request to download an example PDF File to  WRONG URL
Binary size is empty that means API did not return a file


Hope it helps
Ferhat