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

Getting 400 Bad request when using the swagger-ui. #15

Closed
sque opened this issue Jan 21, 2015 · 4 comments
Closed

Getting 400 Bad request when using the swagger-ui. #15

sque opened this issue Jan 21, 2015 · 4 comments

Comments

@sque
Copy link

sque commented Jan 21, 2015

Using swagger-ui I always get 400 Bad request if there is at least one argument for parsing. For endpoints that have no parameters it works just fine. Notice that the API works with no problem if I consume it from any other client, even the same browser by just requesting the URL in a different window.

After investigation I found that it was a problem of swagger-ui client that it always puts the 'Content-type: application/json` even for GET requests. Werkzeug or Flask(not sure) finds illegal putting content-type header without having any HTTP payload (the case of GET), thus the 400 Bad request.

@noirbizarre
Copy link
Owner

It's also flask-restful bug that has been fixed upstream but not yet released: flask-restful/flask-restful#366

@sque
Copy link
Author

sque commented Jan 22, 2015

In the beginning I thought that putting Content-Type for GET request is violation of HTTP/1.1, so for me, it was definitely client's problem. Based on this discussion, I understand that there is no explicit rule in the HTTP/1.1 specification that forbids this rule. So, it was at flask-restful the right place to fix it, but it is also good that the swagger-ui client reduced this abuse of 'content-type' header with their new release.

Thanks, everyday learning :) Hope to see these changes released soon, it is a PITA bug for development :P

@noirbizarre
Copy link
Owner

Yeah, that's what's interesting in programming: you learn every day !! :)

I'm waiting too for flask-restplus release because me too I've been spending a lot of time trying to figure out what's happening !! :)
In the mean time, you could simply do until the new release:

pip install http://github.com/flask-restful/flask-restful/tarball/231da4b

@noirbizarre
Copy link
Owner

It should have been fixed in Flask-restful 0.3.2.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants