If we invoke the Service Callout policy twice in the same API Proxy, it's base path getting appended

If a serviceCallout Policy is called twice in same request it's base path getting appended.

As shown in the attached screenshot, you can notice that

  • The servicecallout.requesturi in the first invocation to Service Callout policy shows it as "/get"
  • However, when the same Service Callout policy is called the second time, the servicecallout.requesturi shows it as "/get/get".

Though the variable servicecallout.Service-Callout-1.target.url shows the value as "http://httpbin.org/get", the request goes as "http://httpbin.org/get/get" and results in a failure "404 Not Found" only for the second request. While the first invocation to Service Callout policy succeeds.

So, wanted to check are we allowed to use the same serviceCallout twice in the same API request?

0 8 1,107
8 REPLIES 8

Hi Amar

Ive been able to reproduce the issue you're experiencing. It appears to be concatenating the servicecallout.requesturi to itself. This does not look like expected behaviour to me, and I will ensure a bug is raised.

With that said, what is your use case that you require multiple requests to the same endpoint?

Hi Amar

Did you manage to get answer to this question. I'm also struggling with the same thing. I have SC policy for logging and I call it to log request and response.

I created two different service callouts but the second concant the before path. Example: the first service callout go to URL http://apigee.com/hello and the second service callout go to URL http://apigee.com/bye. Finally the second service callout is calling http://apigee.com/hello/bye. Why?

Hi Fredwin,

Please use both request variable name different.

eg:

1.

<Request clearPayload="true" variable="myRequest"></Request>

2.

<Request clearPayload="true" variable="myRequest1"></Request>

This should work

Not applicable

You can set the service callout url using assign message policy to a variable and set that as a variable in the service callout. That will not append the base path.

Hi Amar ,

Servicecallout.requesturi flow variable gets duplicated because of the request variable name , as the request variable name is same , path gets appended twice when it called second time.

I would suggest use two different service call out policy and keep request variable name different for both Service callout policies , even though you keep same <path> for both policies.

eg:

1.

<Request clearPayload="true" variable="myRequest"></Request>

2.

<Request clearPayload="true" variable="myRequest1"></Request>

I hope this works for you

I have tried this and it worked for me..