I am working with Azure API Management (APIM) and have created an API without defining specific operations, applying policies at the All operations level. The API is intended to function in a No-Operation mode, where policies at the API level should rout

Anand Singh 0 Reputation points
2025-02-19T19:15:33.4266667+00:00

I am working with Azure API Management (APIM) and have created an API without defining specific operations, applying policies at the All operations level.

The API is intended to function in a No Operation mode, where policies at the API level should route requests to different backends based on the URL path.

However, when sending requests via Postman, I consistently receive:

{
    "statusCode": 404,
    "message": "Resource not found"
}

Used Policy for testing

<inbound>
    <base />
    <choose>
        <when condition="@(context.Request.OriginalUrl.Path.Contains("/get"))">
            <set-backend-service base-url="https://httpbin.org" />
            <rewrite-uri template="/get" />
        </when>
        <when condition="@(context.Request.OriginalUrl.Path.Contains("/posts"))">
            <set-backend-service base-url="https://jsonplaceholder.typicode.com" />
            <rewrite-uri template="/posts/1" />
        </when>
        <otherwise>
            <return-response>
                <set-status code="404" reason="Not Found" />
                <set-body>@("Requested resource not found")</set-body>
            </return-response>
        </otherwise>
    </choose>
</inbound>
<backend>
    <base />
</backend>
<outbound>
    <base />
</outbound>

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
2,303 questions
{count} votes

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.