When you leverage the ServiceCallout policy in Apigee Edge, there are a couple options for creating the HTTP request message used for that callout:
Option #2 can be preferred to avoid an extra policy definition in your API proxy. An example policy for setting the HTTP request message directly in the ServiceCallout policy is below:
<ServiceCallout name="myServiceCallout"> <Request> <Set> <Headers> <Header name="Accept">application/json</Header> </Headers> <Verb>POST</Verb> <Payload contentType="application/json" variablePrefix="%" variableSuffix="#">{"message":"my test message"}</Payload> </Set> <IgnoreUnresolvedVariables>false</IgnoreUnresolvedVariables> </Request> <Response>calloutResponse</Response> <HTTPTargetConnection> <Properties/> <URL>http://httpbin.org/post</URL> </HTTPTargetConnection> </ServiceCallout>
@Michael Russo I'm trying to implement the option 1 without success yet.
I created an AssignMessage policy where I set the header with some variables. Like this:
<Set> <Headers> <Header name="somevariable">{messageid}</Header> </Headers> <QueryParams/> <FormParams/> </Set>
That policy is before the Service Callout policy.
The problem is that on the Edge I see that the header is set but when I check the headers through an echo endpoint (shows the header of the request) on the Service Callout the variables are not there.
Any idea what could be the problem?
Let me know if you want me to create a new thread with the question.
Thanks.