IResponse object in send request

Martin Kallukalam 170 Reputation points

In the send-request policy example I see IResponse object being used

However couldnt find any documentation on this IResponse in APIM.
As a use who will write policies, how can I find all these undocumented things?

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

Accepted answer
  1. Sina Salam 6,966 Reputation points

    Hello Martin Kallukalam,

    Welcome to the Microsoft Q&A and thank you for posting your questions here.


    I understand that you could not find any documentation on IResponse as an example of some of the things you do as a policy writer in Azure API Management, and you would like to know how you can find all undocumented things.


    To solve this challenge, I will use your example for the same. In the case of the IResponse interface and all similar objects in Azure API Management (APIM) policies can be tricky to find in the documentation, as they are often used in inline policy expressions and not explicitly documented as standalone objects.

    How to Discover Undocumented Features

    1. Start with the official Azure API Management documentation -, which includes policy references, samples, and tutorials with other links.
    2. Engage with the Azure community through forums like Stack Overflow, Microsoft Q&A, and GitHub discussions. Often, developers share insights and undocumented features.
    3. Use the Azure Portal's policy editor, which provides IntelliSense and suggestions when writing policies. This can help you discover properties and methods available for objects like IResponse.
    4. Create test APIs and use policies to experiment with different expressions and objects. Log the outputs to understand the structure and available properties.
    5. Microsoft Learn offers courses and modules on Azure API Management. Additionally, the documentation often includes feedback and Q&A sections as you are here is a powerful community where undocumented features might be discussed.

    You can effectively discover and leverage undocumented features in Azure API Management using above steps and combining the response variable holds an object, by access their status property.

    For example, of how you might use the IResponse object in a policy expression:

    <send-request mode="new" response-variable-name="response">
        <when condition="@(context.Variables["response"].status == 200)">
            <set-header name="X-Success" exists-action="override">
            <set-header name="X-Failure" exists-action="override">

    The above response variable holds an IResponse object, and we access its status property.

    Accept Answer

    I hope this is helpful! Do not hesitate to let me know if you have any other questions.

    ** Please don't forget to close up the thread here by upvoting and accept it as an answer if it is helpful ** so that others in the community facing similar issues can easily find the solution.

    Best Regards,

    Sina Salam

    1 person found this answer helpful.
    0 comments No comments

1 additional answer

Sort by: Most helpful
  1. Pinaki Ghatak 2,955 Reputation points Microsoft Employee

    Hello @Martin Kallukalam

    The IResponse object is part of the Azure API Management (APIM) policy expressions and is used in the context of the send-request policy. It represents the HTTP response from the send-request policy and can be used to access the response details such as headers, status code, and body.

    In the send-request policy, the IResponse object can be stored in a context variable and later accessed for further processing. For example, you can retrieve the body of the response as a JSON object.

    Here’s an example of how you might use it:

    <set-variable name="response" value="((IResponse)context.Variables["response"]).Body.As<JObject>()" />

    In this example, the IResponse object is cast from a context variable named “response”, and the body of the response is parsed as a JObject.

    To find more about these undocumented things, you can refer to the Azure API Management policy expressions documentation and community Q&A platforms like StackOverflow. The documentation provides information about the syntax and usage of policy expressions, and the community platforms often have practical examples and solutions to common issues.

    I hope. this answers your question. If so, please tag this is answered.

    1 person found this answer helpful.
    0 comments No comments