Manage synchronous calls to async using API Management

DevBuster007 176 Reputation points

I am using API Management in my project to make REST API calls to external API's.
We have one requirement where:

  1. Client will call us synchronously and will wait for the response.
  2. Our layer/project takes this synchronous call and calls external API: Lets say CreditCheckAPI
  3. CreditCheckAPI only accepts asynchronous calls

How can i use API Management so that i can manage synchronous incoming calls with async calls. I have to respond to our caller synchronously.
Please help.

Azure API Management
Azure API Management
An Azure service that provides a hybrid, multi-cloud management platform for APIs.
1,877 questions
Azure Event Grid
Azure Event Grid
An Azure event routing service designed for high availability, consistent performance, and dynamic scale.
338 questions
0 comments No comments
{count} votes

1 answer

Sort by: Most helpful
  1. Pramod Valavala 20,606 Reputation points Microsoft Employee

    @DevBuster007 You can leverage policies to achieve this and in fact, this sample covers this exact scenario. Here is the same policy for reference.

       <!-- The policy defined in this file demonstrates how to mask an asynchronous API endpoint as if it is an synchronous one. -->  
       <!-- This is useful when modernizing APIs but some clients that call the API cannot be updated to the new behavior. -->  
       <!-- API used for this example is an Azure Logic Apps (request/resposne), in which retruns HTTP 202 status code, -->  
       <!-- and location header to retrieve the terminal payload. Retry count and interval is fixed  in this example but can also be customized. -->  
               <base />  
               <forward-request />  
               <base />  
               <retry condition="@(((IResponse)context.Variables["var"]).StatusCode == 202)" count="10" interval="30">  
                   <send-request mode="new" response-variable-name="var" ignore-error="false">  
               <return-response response-variable-name="var" />  
               <base />