Download attachment file of POST API response from a custom API endpoint

Hi all,

Hopefully you all doing well :slight_smile:

I’m using the POST HTTP request to download all files, but unfortunately I get my .zip file as a string.

Could you please help me how I can download the zip file to the folder from POST HTTP request?

Thank you in advance,

Regards,
Anuka

1 Like

Hi @Anuka_D, I hope you are doing well.
Can you please provide a sample of the .zip file so that we can help you in a better way.

Have a good day!

Thanks & Regards,
Shubham Dutta

1 Like

(post deleted by author)

Dear @Shubham_Dutta ,

Thank you for your time :slight_smile:

My problem is I would like to convert (from binary to PDF/ZIP)and save the attachments from SOAP POST response. Unfortunately I can’t share any sample files, but it is proper .pdf files.

For this task I’m using the HTTP request activity, because the SOAP activity is not accepting my WSDL link.

Thank you in advance,

Regrads,
Anudar

1 Like

Hi @Anuka_D,

Welcome to the Community!

Have you set a value for the ResourcePath property?

image

1 Like

Hi @gustavo.cervelin ,

I already tried this option, but it didn’t work for me. I guess my SOAP web service giving me the binary file. :frowning:

Thanks in advance,

Regards,
Anuka

1 Like

Check the solution from this thread Saving file using HTTP request - #7 by Jun_Wei

2 Likes

Hi @marian.platonov,

Thank you :slight_smile:

I already tried this ResourcePath option and downloaded the file.

Unfortunately I can’t open the downloaded file, because it says something went wrong with the file.
I’m not sure what is the issue, I’m sure the SOAP service sending the file(.pdf/.zip) as binary format. Do you think it could be an issue?

Thanks in advance,

Regards,
Anuka

1 Like

Change the BodyFormat to match the content of your downloaded file. Also, check the Headers parameters to see which is the Content-Type.

1 Like

Hi @Anuka_D,

Has this endpoint been used before? I mean, has anyone been able to successfully download and open a file that was downloaded via a request using this endpoint?

I suggest using postman for a test. You can create a request there and check if the file was downloaded successfully. If not, I’d bet the problem must be on the API side.

image

@Anuka_D

I took a look at a project that I built which uses the HTTP request activity to save a .zip file, and I noticed some things and decided to share with you:

  1. AcceptFormat is set to ANY
    image

  2. The ResourcePath value includes a name and the extension for the file. I am not sure if it works if you provide only the folder name.
    image

  3. In my case, the Content-Type Header was not used and it works.

Thank you @gustavo.cervelin and @marian.platonov

I checked my endpoint with SoapUI . The endpoint is correct and I was able to download/open correctly my file in SoapUI.

in SoapUI I can see next details regarding the response and attachments: (Not much I can share, sorry about that! )
image

So I tried to configure below parameters in UiPath:

  1. AcceptFormat=Any:
    image

  2. in the UiPath: I set the BodyFormat=application/octet-stream
    image

  3. I also set up Content-Type: text/xml, in case maybe needed.

  4. I also filled the RecoursePath parameter.

However I noticed that the attachment file is changing each response of the SOAP POST call. Which means somehow the file name and extension needs to dynamic in RecoursePath parameter. ( RecoursePath: “DownloadingFolderPath”+this part needs to be dynamic (Because I wont know what kind of file is coming in the response)

I think this is the reason why I can’t download my files. Do you have any suggestions?
Thanks in advance,

Regards,
Anuka

1 Like

Check in the response headers if you have something like Content-Disposition. There you should see the filename. (exactly what you will need)

====

For example, to download a nupkg package from our UiPath Orchestrator, we need to provide these details in the Headers:

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