APIM send-request to self

I had a scenario that required multiple send-requests to be executed inside a policy. One of the send-requests needed to be made to another API operation hosted on the same APIM instance. Using the FQDN resulted in a HTTP 404 not found response.

The following can be used within a policy if you need to make an API call to an API hosted within the same instance of APIM:

<send-request ignore-error="false" timeout="300" response-variable-name="internalAPIOperationRequestResponse" mode="new">
            <set-url>https://127.0.0.1/my/api/v1/operation/?param1=hello&amp;param2=world</set-url>
            <set-method>GET</set-method>
            <set-header name="Host" exists-action="override">
                <value>my-apim.azure-api.net</value>
            </set-header>
        </send-request>

The important part to note is that you must use https://127.0.0.1 in the set-url in place of the FQDN. You must also declare the Host header with the domain name of your APIM instance.

Leave a Comment