Response body has "no content" in Swagger UI

2,038 views
Skip to first unread message

Andrew McFarland Campbell

unread,
Jan 20, 2016, 10:38:03 AM1/20/16
to Swagger
Hi,

I'm having problems with Swagger UI


Swagger UI loads the yaml without any problems when I enter the URI into the URI field and click "Explore".

There is one end point in my .yaml. When I click "Try it out", I get the following results:

Response Body

no content

Response Code

0

Response Headers

{
"error": "no response from server"
}

The curl works on the command line, and the request URI is correct.

Can anyone help me fix this?

tony tam

unread,
Jan 20, 2016, 11:36:23 AM1/20/16
to swagger-sw...@googlegroups.com
Most likely, the swagger-js client inside swagger-ui cannot reach your server.  Perhaps a CORS issue?

If you can open the debug tab in your browser and share any errors, that’d be helpful.

--
You received this message because you are subscribed to the Google Groups "Swagger" group.
To unsubscribe from this group and stop receiving emails from it, send an email to swagger-swaggers...@googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

Message has been deleted

Andrew McFarland Campbell

unread,
Jan 20, 2016, 12:00:26 PM1/20/16
to Swagger
From the javascript console:

swagger-ui.js:1715 server doesn't consume application/x-www-form-urlencoded, try ["application/json"]
(index):1 XMLHttpRequest cannot load http://internal.url/path/to/resource. Response to preflight request doesn't pass access control check: No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://127.0.0.1' is therefore not allowed access.
2swagger-ui.js:1715 server doesn't consume application/x-www-form-urlencoded, try ["application/json"]

Where "http://internal.url/path/to/resource" is the URI for the resource.

tony tam

unread,
Jan 20, 2016, 1:21:40 PM1/20/16
to swagger-sw...@googlegroups.com
Looks like you need to enable CORS then.  Do you have the ability to return 200 for OPTIONS requests?  Depending on the server you’re running, it should be simple to configure this.

Andrew McFarland Campbell

unread,
Jan 21, 2016, 4:21:29 AM1/21/16
to Swagger
Thanks. I don't control the server, but I'll speak to the team that does.

Ron Ratovsky

unread,
Jan 22, 2016, 4:58:03 PM1/22/16
to swagger-sw...@googlegroups.com
If you don’t control the server but still want to get this to work, you can use a CORS proxy, at least for initial testing.

--

Andrew McFarland Campbell

unread,
Jan 29, 2016, 5:42:43 AM1/29/16
to Swagger
I finally got this working: our solution was to host the Swagger and Swagger-UI on the same server as the API itself, and it all just worked.

Thanks for all the help!
Reply all
Reply to author
Forward
0 new messages