Service Callout Lost Suffix

I have a question regarding Service callouts. 

 

I have a proxy which, in the flow calls another proxy for a token acquisition.  Now the thing is

Apigee just ignores the intial suffix in the service callout and resets it to "/". Is there any easy way to tell Apigee to forward the same suffix to the Service callout proxy? 

 

I can think of multiple workarounds how to achieve this, but is there a clean way? 

 

I tried this for example:

<Request clearPayload="true" variable="myRequest">
<IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables>
<Set>
<Path>/{proxy.pathsuffix}</Path>
</Set>
</Request>
<Response>calloutResponse</Response>
<LocalTargetConnection>
<Path>/fetch-token</Path>
</LocalTargetConnection>
</ServiceCallout>

The thing is, if the initial suffix has two slashes, something like: /bla/blub then the code above ignores the "/bla" and just adds the "/blub" as the new suffix in the callout proxy. 

 

Any help is appreciated. 

0 2 167
2 REPLIES 2

Setting the path in the ServiceCallout Request is the right way to do what you are describing.  The ServiceCallout policy does not automatically append paths to the outbound request. That happens with the target request in an Apigee proxy, but not with requests that you explicitly make, as with ServiceCallout.  If you want a path on the ServiceCallout request, you need to explicitly set it. 

Just to level set. Every proxy listens on a basepath. That basepath must be unique for all proxies deployed to an environment (or in Apigee X, an environment group).

Let's say in your case, the front proxy has a basepath of /abc.

Then every request that has a left-most path of /abc will be forwarded to that proxy.  If the request is GET /abc/123, the proxy with the basepath of /abc will handle the request. 

At runtime, the variable proxy.pathsuffix will get the portion of the path to the right of the basepath. In our example, proxy.pathsuffix gets /123. 

If at runtime you want the basepath for the current proxy, you can get it by reading the proxy.basepath variable.

More on these variables here.

 

The path you specify in the ServiceCallout should have as its left-most portion, the basepath of the "behind" proxy, the one you want the front proxy to call.  And everything to the right of that does not matter, for the purposes of routing the request.

Also since you are using a LocalTarget in the ServiceCallout, here's an older post relevant to that.

Yes, the path suffix will not automatically get added in service callout. You need to append that using variable inside the service callout policy as below.

Show More
<HTTPTargetConnection>
   
<URL>http://example.com/{proxy.pathsuffix}</URL>
</HTTPTargetConnection>