Get hands-on experience with 20+ free Google Cloud products and $300 in free credit for new customers.

Can api invoke other api in the same proxy ?

For example:

I have created proxy Test with base path /test/v0 and it contain 2 api A  and B.

The flow I expected is

When client call apiA -> apiA invoke apiB and do some process -> apiB response to apiA -> apiA response to client.

It is possible to implement? Please give me some advice.

Thank you

0 5 191
5 REPLIES 5

Hi @pimonnat ,

It's possible to implement in APIGEE to call one proxy from another proxy. We call it as proxy chaining. Go through the below link for more understanding.

https://cloud.google.com/apigee/docs/api-platform/fundamentals/connecting-proxies-other-proxies

Also, you can call multiple backend URL's in single proxy by using service call out policies.

I have try but it not working, here is my example

Proxy endpoint

<ProxyEndpoint name="default">
	<PreFlow/>
	<Flows>
		<Flow name="apiA">
			<Request/>
			<Response>
				<Step>
					<Name>AssignMessageReturnResponse</Name>
				</Step>
			</Response>
			<Condition>(proxy.pathsuffix MatchesPath "/apiA")</Condition>
		</Flow>
		<Flow name="apiB">
			<Request/>
			<Response>
				<Step>
					<Name>JS-SetResponse</Name>
				</Step>
			</Response>
			<Condition>(proxy.pathsuffix MatchesPath "/apiB")</Condition>
		</Flow>
	</Flows>
	<PostFlow/>  
	<HTTPProxyConnection>
		<BasePath>/test/v0</BasePath>
		<Properties/>
		<VirtualHost>default</VirtualHost>
	</HTTPProxyConnection>
	<RouteRule name="callback">
        <TargetEndpoint>callback</TargetEndpoint>
        <Condition>(proxy.pathsuffix MatchesPath "/apiA")</Condition>
    </RouteRule>
</ProxyEndpoint>

 

 

Target Endpoint

<TargetEndpoint name="callback">
    <PreFlow name="PreFlow">
        <!-- PreFlow policies -->
    </PreFlow>
    <PostFlow name="PostFlow">
        <!-- PostFlow policies -->
    </PostFlow>
    <LocalTargetConnection>
        <Path>/apiB</Path>
    </LocalTargetConnection>
</TargetEndpoint>

 

I test by calling /apiA it is not error but the AssignMessageReturnResponse not received the value that I set in JS-SetResponse

and trace session appear only one transaction /apiA, do not transaction of /apiB

What should I do ?

Hi @pimonnat !

Do I get it right that you want your proxy to call itself via proxy-chaining?

If so, then what's the reason behind it, what's your goal/usecase?

Could you please try defining the proxy-chaining in this way, instead of using the path element?

Replace "ProxyB" with the name of your proxy.

<TargetEndpoint>
  <LocalTargetConnection>
    <APIProxy>ProxyB</APIProxy>
    <ProxyEndpoint>default</ProxyEndpoint>
  </LocalTargetConnection>
</TargetEndpoint>

Thx,
M

Hello,

I am not sure how authentication is being handled as a part of your proxy chaining-workflow, but I would recommend reviewing the following: https://www.googlecloudcommunity.com/gc/Cloud-Product-Articles/How-to-chain-proxies-securely-in-Apig... and potentially utilize the client.local flow variable given use case