0

I am using wso2 API manager 3.2.0 .I want to check incoming requests Content Type that it only allowed to be application/json if any other type sent as content type for example application/xml ,415 Unsupported Media Type as must be show as status code for all resources in a rest API.how can I do this.for example I sent following request and recieve 500 internal server error , my goal is to check content type and if content type was not application/json , statu code 415 Unsupported Media Type show to client as response :

curl --location --request POST 'https://10.10.10.24:8243/pri/general/v1/service1' \
--data ''

1 Answer 1

1

You can create a Custom Mediation Policy and engage the following logic.

<filter regex="application/json" source="$trp:Content-Type">
    <then>
    </then>
    <else>
      <property value="415" name="HTTP_SC" scope="axis2"/>
      <respond/>
    </else>
</filter>
0

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Not the answer you're looking for? Browse other questions tagged or ask your own question.