I added a new get API in my controller of a Rest service, there already have 2 APIs. The API is like below:
@GET
@Path("/alert")
@Consumes(MediaType.APPLICATION_JSON)
@Produces(MediaType.APPLICATION_JSON)
Response getAlert(@NonNull @Context HttpServletRequest servletRequest,
@NonNull @QueryParam("merchantId") String merchantId,
Map<String, String> requestContext);
But when I tried to access it with following url
https://example.com/alert?merchantId=A3C1N4PUSVRODK
The following error returns:
{
"code": "Unsupported Media Type",
"message": "Cannot consume content type"
}
This is the way I used in code to request the url
await axios.get(url, {
headers: {'Content-type': 'application/json'}
});
The previous API in this controller works well in this way, can anyone help to answer what’s wrong here?
When I tried to instead axios.get with fetch as follow, the API can return correctly.
await fetch(url, {
headers: {'Content-type': 'application/json'}
});
But still same error when I access the URL in my browser https://example.com/alert?merchantId=A3C1N4PUSVRODK