Ask a Question

Interactive API Docs 'Try it out!' does not set "Accept" header

SOLVED
ngolubchuk
Occasional Contributor

Interactive API Docs 'Try it out!' does not set "Accept" header

I describe API model on swaggerhub.com and trying to send POST request with parameters in body using 'Try it out!' operation. It returns response with status '406 Not Acceptable'.

However when I copy Curl that suggests swaggerhub and paste it to command line it works fine.

There is no header "Accept: application/json" in request that comes to web app when I use 'Try it out' operation.
In the description of my POST operation there is field

      produces:
        - application/json

I tried to add header using parameters:

      parameters:
        - name: "Accept"
          in: header
          type: string
          default: "application/json"

But result doesn't  changed at all.

When I change header in parameters, I can set changes in represented curl, but result is the same.

 

Is there something I am doing wrong? Thanks in advance for your assistance. 

6 REPLIES 6
ponelat
Staff

Thanks for taking the time write out your issue.

I'll take a quick look, and report back here...

 

Josh

I have found an issue, which is probably causing your missing  `Accept: application/json`.

 

Your spec, looks fine. Sorry for the inconvenience, we'll report as soon as we move the needed changes into production.

 

ponelat
Staff

Thanks again for you patience... the issue should be resolved in production, please feel free to reach out with any other queries.

 

Josh

ngolubchuk
Occasional Contributor

It works now. Thanks for the quick response.

 

Nikita

josebrwn
New Contributor

I am having a similar issue. My curl always looks like this:

 

curl -X GET --header 'Accept: text/html' 

when what I need is this:

 

curl -X GET --header 'Accept: application/json' 

 

Isn't there a simple way to do this? I tried the solution above, to no avail, adding both:

 

produces:
  - 'application/json'

 

and under parameters:

 

      - name: "Accept"
        in: header
        type: string
        default: "application/json"
        description: application/json is currently supported

Any help appreciated!

 

We have a known bug with the curl command generation and working on a fix for it. The try it out functionality should work as expected though.


Did my reply answer your question? Give Kudos or Accept it as a Solution to help others.↓↓↓↓↓
cancel
Showing results for 
Search instead for 
Did you mean: