How to download attachment from Postman Response
Asked Answered
W

1

12

I have a API which sends response having following header:

Headers(8)
Test Results(1/1)
Status:200 OK
Time:5890 ms
Size:1.24 MB
Access-Control-Allow-Origin →*
Cache-Control →no-cache
Content-Disposition →attachment; filename=Report.csv
Content-Length →1298149
Content-Type →text/csv
Date →Fri, 22 Jun 2018 08:50:05 GMT
Expires →-1
Pragma →no-cache

I want to download the attachment file 'Report.Csv'

Can anyone suggest How can I do it via script or newman

Washcloth answered 22/6, 2018 at 8:52 Comment(5)
How does the attachment file is being sent by the server?Whomever
it is coming in response onlyWashcloth
can you paste here a response maybe use «gist», it would be lovely to see how its getting to you. Or if you can make a postman mock with the example and place it here. plsWhomever
Here is the response I am getting: Headers(8) Test Results(1/1) Status:200 OK Time:5890 ms Size:1.24 MB Access-Control-Allow-Origin →* Cache-Control →no-cache Content-Disposition →attachment; filename=Report.csv Content-Length →1298149 Content-Type →text/csv Date →Fri, 22 Jun 2018 08:50:05 GMT Expires →-1 Pragma →no-cacheWashcloth
Postman and Newman are two different tools. A specific question should be limited to a specific tool.Crustal
G
12

If you're sending a request from within the Postman app, you can "Send and download" the response.

...you should select “Send and download” which will let you save the response to your hard disk.

If you're trying to do it by script, here's a tutorial about writing to your local file system by running a local server, or how to use Newman to do something similar.

Goiter answered 28/6, 2018 at 18:13 Comment(3)
I tried using the script but it is not working. The Script mention uses express module. I installed express module in npm but now getting error "cannot find module 'express'". Is there a way to use send and download directly via ScriptWashcloth
@ArchitGoyal did you install the dependences in the current directory? or perhaps your node_modules directory is in another place? https://mcmap.net/q/135194/-node-js-error-cannot-find-module-39-express-39Goiter
I installed the dependencies in the current directory only.Washcloth

© 2022 - 2024 — McMap. All rights reserved.