Content Type header check in policy fragment in Azure API Management

Vikhyath Shetty 25 Reputation points
2024-05-29T09:47:18.3766667+00:00

Hi,

I am trying to verify the content-type in the header of a request that downloads a file from an endpoint through the APIM.

The content-type is "multipart/form-data; boundary=<calculated when request is sent>" when checked in postman.

The policy fragment used to check the header is:

<check-header name="Content-Type" failed-check-httpcode="415" failed-check-error-message="Unsupported Media Type" ignore-case="true"> <value>application/json</value> <value>multipart/form-data</value> </check-header>

However this validation fails for file download request, but works fine for regular JSON requests.

What is the ideal policy code to check for this particular content type?

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,851 questions
0 comments No comments
{count} votes