I created an API with WSO2 API Manager adding my own java Restful Service as Endpoint. Testing the service endpoint worked fine. I subscribed to the API properly but when invoking the API with the swagger it returns the following body content:
<!DOCTYPE html>
<html>
<head>
<title>Apache Tomcat/8.0.45 - Error report</title>
<style type="text/css">
H1 {
font-family:Tahoma,Arial,sans-serif;
color:white;
background-color:#525D76;
font-size:22px;
}
H2 {
font-family:Tahoma,Arial,sans-serif;
color:white;
background-color:#525D76;
font-size:16px;
}
H3 {
font-family:Tahoma,Arial,sans-serif;
color:white;
background-color:#525D76;
font-size:14px;
}
BODY {
font-family:Tahoma,Arial,sans-serif;
color:black;
background-color:white;
}
B {
font-family:Tahoma,Arial,sans-serif;
color:white;
background-color:#525D76;
}
P {
font-family:Tahoma,Arial,sans-serif;
background:white;
color:black;
font-size:12px;
}
A {
color : black;
}
A.name {
color : black;
}
.line {
height: 1px;
background-color: #525D76;
border: none;
}
</style>
</head>
<body>
<h1>HTTP Status 406 - Not Acceptable</h1>
<div class="line"></div>
<p><b>type</b> Status report</p>
<p><b>message</b> <u>Not Acceptable</u></p>
<p><b>description</b> <u>The resource identified by this request is only capable of generating responses with characteristics not acceptable according to the request "accept" headers.</u></p>
<hr class="line">
<h3>Apache Tomcat/8.0.45</h3>
</body>
</html>
An application/xml media type is supposed to be returned!
Here is the screen shot of my swagger after calling the api
Here is the response when calling the service directly from the browser
I have also changed the response media type to application/json but it still did'nt worked too.
Can someone please help me to fix this problem?
The issue is you have message
part at the end of both endpoint
and actual request
. That makes the underneath call becomes
http://localhost:8080/messanger/webapi/messages/messages/
which is an invalid URL.
The solution is simple. Remove the messages
part from the endpoint URL.
i.e. Endpoint URL should be http://localhost:8080/messanger/webapi/