Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Download any response as a file #962

Open
parvizfarnia opened this issue Jun 5, 2023 · 5 comments
Open

Download any response as a file #962

parvizfarnia opened this issue Jun 5, 2023 · 5 comments

Comments

@parvizfarnia
Copy link

Hello

In the download page of RESTer on Mozilla, at the bottom of the page, there is a release note:

Release notes for 4.11.0
Added

  • RESTer will now download response bodies as files, if the response has a Content-Disposition: attachment header.

I have installed the 4.11.0 version, yet I don't see this option available.

Is that normal?

Thanks in advance.

@frigus02
Copy link
Owner

frigus02 commented Jun 8, 2023

Sorry for the slow response. There is no visible option for it in the UI. RESTer should open a file save dialog if the response contains the appropriate header, e.g. Content-Disposition: attachment; filename=hello.txt.

If this doesn't work for you, it sounds like a bug. Can you share the response headers where you expected RESTer to download the response as a file?

@parvizfarnia
Copy link
Author

Thank you for your help.

Actually, I'm not even sure that I'm sending the query correctly. Because looking the value you specified, I never put any filename.

Here is the context. I use RESTer to query a REST API. Here is what I have in my header inside RESTer screen when I send my query

Method: GET
Authorization: Bearer <And then I write my token>
Accept: application/json

Now sometimes, I need to get the result in CSV format instead of JSON. In that case, I write Accept: text/csv. But in this way, I don't get the result in a file and I have to simply copy/paste the result from RESTer screen into Excel/Calc. But recently I noticed that apparently there is Content-Disposition functionality. I said, well that would be quite more appropriate to use instead of doing each time a copy/paste.

As you suggested I tried to add the following to my query header:

Content-Disposition: attachment; filename=hello.txt

But nothing happend in terms of downloading. The query succeeded as usual (HTTP code 200) but that's all. Here is the response header

Cache-Control: no-cache
Access-Control-Allow-Origin: *
Access-Control-Allow-Methods: POST,GET
Content-Encoding: gzip
Vary: Accept-Encoding
Expires: Thu, 01 Jan 1970 00:00:00 GMT
X-Total-Count: 26329955
Access-Control-Allow-Headers: authorization,Access-Control-Allow-Origin,Content-Type,SOAPAction
Link: <I erased the content here as it is confidential>
Content-Type: text/csv;charset=utf-8
Date: Tue, 13 Jun 2023 07:57:21 GMT
Transfer-Encoding: chunked
Connection: keep-alive
Set-Cookie: pdapimgateway=<I also erased the content here>...; expires=Tue, 13-Jun-2023 08:17:21 GMT; path=/; Httponly; Secure
Strict-Transport-Security: max-age=100000; includeSubDomains

@frigus02
Copy link
Owner

Content-Disposition must be a response header for this to work. (Not a request header.)

I believe filename is then optional, but it should test to make sure.

It sounds like in our case an option in the UI to download the response as a file would be helpful. Is that correct?

@parvizfarnia
Copy link
Author

Yes. Besides, unless I have not understood how RESTer functions, it seems to me that currently a user has only the possibility of setting request headers in RESTer's UI. Am I right?

@frigus02
Copy link
Owner

Yes, RESTer can only set request headers. Content-Disposition is a response header only the responding server can set it.

I'll take this as a feature request to download any kind of response as a file.

@frigus02 frigus02 changed the title Download response as a file with Content-Disposition: attachment not available in RESTer v. 4.11.0 Download any response as a file Jun 20, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants