0
votes

I'm currently working through the Mulesoft Mule 4 Fundamentals course and have deployed an application on Runtime Manager.

When I look in the logs of my application on Runtime Manager and the logs of Anypoint Studio I see the above "Unsupported Media Type" error when testing a GET HTTP request. I also get this error when testing in ARC.

When I look in the Mule debugger and then the payload in Anypoint Studio I see mediaType = */* charset = UTF-8

I thought that this does not need to be added for GET requests, so how do I get around this?

My RAML file:

#%RAML 1.0
title: session-2

types:
  newsProperties: !include schemas/newsDataType.raml

/search:
  get:
    headers:
      Accept:
        default: application/json
    queryParameters:
      keyword:
        type: string
        minLength: 3
        maxLength: 10
    responses:
      200:
        body:
          application/json:
            example: !include examples/searchExample.raml
      400:
        body:
          application/json:
            example:
              {"message": "Search query too long"}
/news:
  post:
    queryParameters:
      country:
        required: false
    body:
      application/json:
        type: newsProperties
    responses:
      201:
        body:
          application/json:
            example: !include examples/searchExample.raml

/sportsNews:
  put:
    body:
      application/json:
        type: newsProperties

The header in the /search resource GET method has been added recently after searching online and trying a number of different solutions I've seen, but I am still getting the same error. Any help would be appreciated.

Thanks!

3

3 Answers

0
votes

Probably you are not setting the Content-Type header to application/json and the API implementation is expecting it.

0
votes

Hello try to include a json example instead a raml example:

!include examples/searchExample.raml convert it to include json example.

!include examples/searchExample.json

0
votes

I had this same problem and I solved it by mapping the endpoint on Router (apikit:config). Then I figured out the name set to the router was different on the endpoint flow, like:

  • Flow name: get:(userId):api-config
  • Router name: users-api-config

Fixing the name on flow or mapping the method on router solve this problem