How to call a local proxy after getting the data from a microservice

Hello Team,

I am new to APIGEE and i have one requirement, where:

- From an API proxy i have to hit one microservice and depending on the response i get from the service (json), i have to call different types of API Proxies.

example:

If(resp =1) call \proxy 2

if(resp =2) call \proxy 3 etc


Can anyone help me on how to proceed further with this usecase?

Regards,

Aswin

0 2 478
2 REPLIES 2

sidd-harth
Participant V

Hi @Aswin Kumar, yes Apigee can be used to hit one service and based on the response we can call other services. But if you are using Apigee Cloud account, then you cannot call local services/proxies deployed/running on your local machine.

Apigee Cloud can access public http/rest URLs.

We have Apigee On-Premise(paid version) which can be used to run apigee on a private machine and it can then access services running on that machine.

--

BTW what do you mean by local proxy?

Hi @Aswin Kumar

You can use the LocalTargetConnection tag (instead of HTTPTargetConnection) to chain proxies instead of calling out to an HTTP service. This works in both ServiceCallout policies and target endpoints. If you use targets, you would use RouteRules to determine which one to call. If you use ServiceCallout, you can use conditions on the policies or conditional flows to select only one.

For targets, treat it the same as a normal target -- the proxy.pathsuffix should be appended to the basepath for the call.

Here is a ServiceCallout example:

<ServiceCallout async="false" continueOnError="false" enabled="true" name="SC-ChainProxy">
    <DisplayName>SC-ChainProxy</DisplayName>
    <Properties/>
    <Request>
        <Set>
            <Verb>GET</Verb>
            <Path>/widgets</Path>
        </Set>
        <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
    </Request>
    <Response>calloutResponse</Response>
    <LocalTargetConnection>
        <APIProxy>proxy-chaining-dest</APIProxy>
	<ProxyEndpoint>default</ProxyEndpoint>
    </LocalTargetConnection>
</ServiceCallout>

Note the Path setting in the Request -- this is an example of how you can set the path suffix (the part of the path that follows the base path). Assuming the proxy "proxy-chaining-dest" has a basepath of "/foo", this will be similar to calling

GET https://{org}-{app}.apigee.net/foo/widgets