Return the response of a service callout as the proxy response

Not applicable

I have a service callout storing its response in a variable <Response>calloutResponse</Response>.

How can I copy the entire response into the proxy response? I realise I can use an assign message to copy specific components from one message to another but I can not see a simple way to simply copy the entire message (including all headers) into the response.

Solved Solved
1 9 2,809
1 ACCEPTED SOLUTION

Former Community Member
Not applicable

One easy way to copy the entire response (including headers, payload etc) in one step is to use a javascript policy:

context.setVariable("response",context.getVariable("calloutResponse"))

Where "calloutResponse" can be the response returned as part of the service callout step.

View solution in original post

9 REPLIES 9

I'd like to understand the underlying problem here... why not just have this request as the target request instead of the service callout? Are you using the target request for something else?

The service call out request is constructed dynamically use parts of the original request and the result of a previous service call out for verification. If the response from this service callout matches some criteria then its response is returned, otherwise another response might be returned as the 'response'. That said I will have a look at seeing if i can switch the logic to convert from a service call out to a target endpoint instead...

Hey @JamesSBuchanan -- good to see you on here. If there's only 1 target needed, Sean's recommendation is better since it is clear what's happening in the API proxy for a subsequent proxy developer. You will still be able to modify the response based on certain conditions after receiving the response from the target server (vs. service callout server).


Good question!

Former Community Member
Not applicable

One easy way to copy the entire response (including headers, payload etc) in one step is to use a javascript policy:

context.setVariable("response",context.getVariable("calloutResponse"))

Where "calloutResponse" can be the response returned as part of the service callout step.

I will try that, it seems that a lot of the solutions rely on dropping into javascript. Is there a place to raise feature requests for Policy's?

this is a vague answer, I am baffled at how misleading Apigee docs are. How do you return the response of a Callout in it entirety to the Client? There is not even one doc that explains this. It is incredible that we are left dangling like this by Google.

Hi, 

I'm sorry you're dissatisfied. Rather than adding a comment to a 5-yr old thread, Maybe you could ask a new question, and provide your own details. 

We'll try to help. 

ask-a-new-question.png

this does not work:

"response: undefined"