2
votes

I have published API in WSO2 using swagger JSON. After publish I am trying to call rest api using swagger in APP Console. It says

Response Body no content

Response Code 0

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

There is no any error on server which will help me to understand problem.

Here is the request URL which I am using in local server : https://192.168.1.118:8243/api/2.0/questions/1/answers?start=1&end=1&fields=answerId%2CanswerDescription%2CcreateDate

3
Can you enable HTTP wire logs by enabling/adding log4j.logger.org.apache.synapse.transport.http.wire=DEBUG in <APIM_HOME>/repository/conf/log4j.properties file?Abimaran Kugathasan
Why it is calling OPTIONS for GET method? TID: [-1] [] [2016-05-19 19:00:30,431] DEBUG {org.apache.synapse.transport.http.wire} - >> "OPTIONS /api/1.0questions/1/answers?start=1&end=1"sachin dhus
OPTION call is done as a preflight request to check whether it has permission to do the actual request. see en.wikipedia.org/wiki/Cross-origin_resource_sharingChamila Adhikarinayake

3 Answers

1
votes

In my API there are some custom header parameter. Because of this custom header parameter it was not working. I have added custom header parameter in api-manager.xml file.

<Access-Control-Allow-Headers>authorization,Access-Control-Allow-Origin,Content-Type,loggedInUserId,accessToken,clientToken</Access-Control-Allow-Headers>
0
votes

I have faced a similar issue. I have edited the URL(from apicreator login) after it was published for first time and published it again. But the changes were never reflected. WSO2 was pointing to the old URL. Check the logs for error at "WSO2 HOME\repository\logs\wso2-apigw-errors" . Create another version and publish again and it should work.

0
votes

The error is real, but misleading. In most likelihood, you've set the spec so that it returns a specific content type (say, application/json) but you actually return plain text (like a string or a number). swagger-ui expects it to be a JSON, tries to parse it and fails, giving you the wrong error message. However, it does mean your spec does not match what your API actually does.