Loopback API proxy
What is a loopback service?
It receives the request from the client, processes it, and responds without calling the backend service.
Any modifications to the response can be done inside the proxy.
The loopback service can also be used as a dummy back-end service.
Example: Client requests for JSON message to an API proxy. we need to construct and JSON response message inside the Apigee. And send the response back to the client.
To create a No-target API proxy.
click on API proxies.
click on CREATE NEW
Click on No target
Fill Name and Base path in the Proxy details as shown below.
click on Next.
As of now select security options as Pass through and don't check Quota. Click on Next.
Select the Environment(eval), where this proxy is going to be deployed. Click on Create and deploy
Add a GET conditional flow. This proxy will accept only GET requests from the client. if the Client sends, other than a GET request proxy will through an error.
Click on, Proxy Endpoint -> default -> +(front of the default).
Fill details as shown below. Click on Add
getCustomer
conditional flow added.
To add Assign message Policy.
Click on, Proxy endpoint -(inside)-> getCustomer --> Request Flow --> +Step
Select Assign Message Policy from the list. Click on Add.
Assign Message policy code should look like below.
<?xml version="1.0" encoding="UTF-8" standalone="yes"?>
<AssignMessage continueOnError="false" enabled="true" name="Assign-Message-1">
<DisplayName>Assign Message-1</DisplayName>
<Properties/>
<Set>
<Headers/>
<QueryParams/>
<FormParams/>
<Verb>POST</Verb>
<Payload contentType="application/json">
{
"ID": "58",
"Name": "ABC",
"Age": "45"
}
</Payload>
<Path/>
</Set>
<IgnoreUnresolvedVariables>true</IgnoreUnresolvedVariables>
<AssignTo createNew="false" transport="http" type="request"/>
</AssignMessage>
See the output in Postman.
Refer to the below link To download and test the API in Postman.
https://www.outrightcrm.com/blog/postman-api-testing/
Generate the request message
https://hostname//proxy_base_path/contional_flow_path(optional)
Successfully got the JSON message.
Subscribe to my newsletter
Read articles from Nainaz directly inside your inbox. Subscribe to the newsletter, and don't miss out.
Written by