Hi, I have a requirement to access the variables available in session in Payload of ServiceCallout Policy. But I didn't find any examples/documents related to that. Please share the docs or examples to use the access variables in Payload.
Example: Suppose If I wanted to pass the 'apiproxy.name' in the subject variable in JSON Payload of ServiceCallout. What is the syntax to use it?
Ex ServiceCallout:
<ServiceCallout async="false" continueOnError="false" enabled="true" name="SendMailServiceCallout"> <Request clearPayload="false" variable="myRequest"> <Set> <Headers> <Header name="Accept">application/json</Header> </Headers> <Verb>POST</Verb> <Payload contentType="application/json" variablePrefix="%" variableSuffix="#"> {"from":"test","to":"test1","subject":"Test Subject email","html":"Test body email"} </Payload> </Set> </Request> <Response>calloutResponse</Response> <Timeout>60000</Timeout> <HTTPTargetConnection> <URL>http:/test.apigee.net/v1/abc</URL> <SSLInfo /> <Properties /> </HTTPTargetConnection> </ServiceCallout>
Solved! Go to Solution.
Hi @Swapna
Following change should help in this scenario: "subject":"%apirpoxy.name#"
As @sgilson has suggested, AssignMessagePolicy provides much more flexibility. In fact, ServiceCallout being a generic scenario, recommendation is to use three policy in the sequence; AssignMessage,ServiceCallout, and ExtractVariables. Following resources may be helpful:
1. http://apigee.com/docs/api-services/cookbook/using-policy-composition
Sample code is available here:
https://github.com/apigee/api-platform-samples/tree/master/doc-samples/policy-mashup-cookbook
Cheers, Rajesh Doda