I am using Mulesoft Anypoint Platform to design a REST API. I am expecting a JSON response from REST API but I am getting XML response.
I have written below RAML file -
#%RAML 1.0
baseUri: https://mocksvc.mulesoft.com/mocks/aa0b3fb6-9fd7-4196-991e-d030a25bc84b #
title: American Flights API
version: 1.0
mediaType: application/json
/flights:
post:
body:
application/json:
example:
{
"code": "GQ574",
"price": 399,
"departureDate": "2016/12/20",
"origin": "ORD",
"destination": "SFO",
"emptySeats": 200,
"plane": {"type": "Boeing 747", "totalSeats": 400}
}
responses:
201:
body:
application/json:
example: |
{"Message": "Flight added (but not really)"}
I am getting response as below -
<response>
<Message>Flight added (but not really)
</Message>
</response>
In my RAML response body I have mentioned application/json. So not sure why it is not showing JSON response I have written in example and also why it is returning "application/xml" in response code when I have nowhere mentioned "application/xml".
Response headers has Content-Type "application/xml"
content-type:
application/xml; charset=utf-8
date:
Tue, 20 Feb 2018 15:54:26 GMT
server:
nginx
vary:
X-HTTP-Method-Override, Accept-Encoding
x-newrelic-app-data:
PxQFUVNQCwQTUVhXDwcDUFITGhE1AwE2QgNWEVlbQFtcCxYkSRFBBxdFXRJJM3dgZEtOPGttGAsLUl1APjpMSh5IB0sQZGgdHU8QRR5DH1JIBhlRV1MLBQlXVlcbEwBQRh0UVVEHAAYBAVkECg8FCgNHFQdQDUAHOQ==
x-powered-by:
Express
x-request-id:
7a6ebcf4-cc45-491c-8622-00fad8ef3a3e
content-length:
76
connection:
keep-alive
I want to know how I can change the Content-Type to "application/json" in response.
Please help.