8

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

rjdkolb
  • 10,377
  • 11
  • 69
  • 89
Archit Goyal
  • 83
  • 1
  • 2
  • 6
  • How does the attachment file is being sent by the server? – Pablo Palacios Jun 25 '18 at 00:27
  • it is coming in response only – Archit Goyal Jul 24 '18 at 12:46
  • 1
    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. pls – Pablo Palacios Jul 24 '18 at 15:02
  • 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-cache – Archit Goyal Jul 25 '18 at 05:17
  • Postman and Newman are two different tools. A specific question should be limited to a specific tool. – ryanwebjackson Sep 23 '21 at 21:04

1 Answers1

7

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.

J.Lin
  • 1,120
  • 9
  • 11
  • 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 Script – Archit Goyal Jul 24 '18 at 12:48
  • @ArchitGoyal did you install the dependences in the current directory? or perhaps your `node_modules` directory is in another place? https://stackoverflow.com/a/20142467/6815074 – J.Lin Jul 25 '18 at 23:35
  • I installed the dependencies in the current directory only. – Archit Goyal Jul 26 '18 at 07:10