How to setup API management schema for content-type image/png

Billie McQueeney 0 Reputation points
2024-06-06T15:47:44.34+00:00

I am streaming an imagery service through API Management and see the images are being compressed which is causing degradation of the image quality. Looking online it appears I should be able to correct this by setting up a policy. From what I gather I should create a new schema using the schema type XML format. However, when I try to create a new schema using the code below it provides an errors:

  1. Failed to create schema (was caused when I used
Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,905 questions
{count} votes

1 answer

Sort by: Most helpful
  1. JananiRamesh-MSFT 23,251 Reputation points
    2024-06-12T11:21:57.27+00:00

    @Billie McQueeney Thanks for reaching out. Azure API Management (APIM) automatically decides whether to use chunked or whole transfer encoding based on the size of the payload and other factors, and you cannot explicitly configure it.

    If the backend is returning chunked transfer encoding and you want to buffer the response and send it as whole transfer encoding to the client, you can use the set-body policy in the <outbound> section of your policy to buffer the response.

    Here is an example of how you can use the set-body policy to buffer the response:

    <outbound> <base /> <set-body template="none">@{return context.Response.Body.As<string>(preserveContent: true);}</set-body> </outbound>

    By using this policy, you can ensure that the response is sent as whole transfer encoding to the client, even if the backend is returning chunked transfer encoding.

    do let me know incase of further queries, I would be happy to assist you.

    0 comments No comments