Response returns html content instead of json

0
I’m trying to import (GET) data (by creating json structure and import mapping)  from another Mendix app which should be in the json format. The response sends html instead of json Added custom headers in  ‘call rest’ activity to accept only ‘application/json’ but didn’t work. Note: The swagger URL shows json being retreived but at the time of mapping in the consuming app, the response shows as html   Request in Log  (updated by changing endpoint link) Request content for GET request to http://localhost:8080/rest/myservice HTTP/1.1 Content-Type: application/json Accept: application/json   Response in Log (updated by changing link) Response content for GET request to http://localhost:8080/rest/myservice HTTP/1.1 200 OK Date: Wed, 09 Nov 2022 16:28:27 GMT Content-Type: text/html;charset=utf-8 Content-Length: 1384 <!-- HTML for static distribution bundle build --> <!DOCTYPE html> <html lang="en">   <head>     <meta charset="UTF-8">     <title>Swagger UI</title>     <link rel="stylesheet" type="text/css" href="/rest-doc/swagger-ui.css" >               <style>       html       {         box-sizing: border-box;         overflow: -moz-scrollbars-vertical;         overflow-y: scroll;       }       *,       *:before,       *:after       {         box-sizing: inherit;       }       body       {         margin:0;         background: #fafafa;       }     </style>   </head>   <body>     <div id="swagger-ui"></div>     <script src="/rest-doc/swagger-ui-bundle.js" charset="UTF-8"> </script>     <script src="/rest-doc/swagger-ui-standalone-preset.js" charset="UTF-8"> </script>     <script>     window.onload = function() {       // Begin Swagger UI call region       const ui = SwaggerUIBundle({         url: "http://localhost:8080/rest-doc/rest/myservice/swagger.json",         dom_id: '#swagger-ui',         deepLinking: true,         presets: [           SwaggerUIBundle.presets.apis,           SwaggerUIStandalonePreset         ],         plugins: [           function () { return { components: { Topbar: function() { return null; } } } }         ],         layout: "StandaloneLayout"       })       // End Swagger UI call region       window.ui = ui     }   </script>   </body> </html>
asked
5 answers
1

The base location of the URL you need should be in the Published REST Service → General → Location attribute. The exact location of the URL for each endpoint will be in the Published REST Service → General → Resources list. When you open this you should have an Example location attribute you can copy.

https://docs.mendix.com/howto/integration/publish-rest-service/

I hope this helps.

answered
0

Hi Farkhanda,

 

Add the header to your call:    Accept     ‘application/json’

 

Go Make It

(Please accept the answer if it worked for you)

answered
0

Hi Farkhanda,

Please post your headers and response 

answered
0

Your URL has rest-doc in it, which will give you the swagger documentation you are seeing.

Try removing rest-doc from the URL and checking if this works.

Good luck.

answered
0

Hi,

 

Your endpoint should be http://localhost:8080/rest/rest/myservice/v1 instead of http://localhost:8080/rest-doc/rest/myservice/v1

 

Regards, Thijs

answered