I m trying to download attachment from a API call using HTTPS REQUEST activity
I m aware that I can pass the Filename I want that gets downloaded as the attachment
But if the api can have any type of attachment in it like .eml or xlsx file, How can I mention the Filename and filetype of the attachment without knowing what it would be from api
When I tried the same with postman (with Save and Download option) I m able to download the file with its actual name and filetype
But in studio I couldn’t
Is there any way to get any type of attachments from api with its actual file name and file type
A list of different options which can be used or combined:
Response Header - Content-Type
Sending a Previous Call using HTTP Method: HEAD
Using a newer version of Http Request - and retrieving the FileName from the ILocalRessource
Can check a few options more / sometimes we can better catch info with a custom HttpClient implementation of the Call
retrieving the FileName from the ILocalRessource
Can u guide me with this
can be used or combined:
suggestion would be to start with HTTP/Header/Content-Disposition / Location catching
when this is fine for you. Do you have any url to run the demo against?
I use a coupe api url
Where I’m passing url to get the attachment like this
Where I m getting the attachment id from another url
With the above url I get Json response but it is of junk characters. I think it is trying to parse through the attachment and give as output response and it doesn’t have any Filename or filetype
With the url I use to get attachment id also doesn’t give any other details of the attachment
Content-Disposition will be a good option to find the file name.
I have tried a sample, in this content disposition is not available so used content type.
Http_DownloadUnknownFile.zip (2.9 KB)
Hope this helps.
Can you please check the following (we would like to check for a flat solution approach)
yellow Mark - set your URL
myHTTPClient.SendAsync(new HttpRequestMessage(HttpMethod.Head, strURL))
then check in immediate panel:
is it showing the full URI with filename and extension?
with the HEAD Request we ask for meta and are not doing the download
we do feel that we will enhance it
May I know what datatype u r referring for this variables
I couldn’t find that type even though I have
system.net imported @ppr
Are you running on legacy?
Even I don’t have an option to change the project type
It’s 2020.10.6 version
Can u pls forward me this with mail
I couldn’t open for some reason
when working with Legacy we would reference the following:
we did run some side-by-side checks along with different scenarios and cross-checking in Postman.
For a more reliable solution, we would recommend to set up a cascade:
check if Content-Disposition Header is available
check if the request URL can be used
Check if the above shown Result.RequestMessage.RequestUri give details
It can happen, that a file name / info still cannot be determined. Then derivation from content-type or a default name can be used as alternate / fallback
Kindly note: not every content-type allows a clear derivation of the filetype / type extension
Appreciate ur kind help
I got it resolved with Nithin’s suggestion by getting Content Deposition where it had the Filename and filetype which I used for saving my file from api
Content Deposition OR content type
We keep in mind that Content Deposition is an optional header
Within the implementation we had seen:
Can you please clear what was finally used?
For a check call you could use e.g
U r right
It’s Content-Type which has the Filename and type
This topic was automatically closed 3 days after the last reply. New replies are no longer allowed.