I was trying Dino's AWS Signing V4 - Java callout. In Target Request Pre-flow:
1. I was using AssignMessage to prepare request.
<AssignMessage continueOnError="false" enabled="true" name="AM-ConstructBackendRequest">
<DisplayName>AM-ConstructBackendRequest</DisplayName>
<Properties/>
<Remove/>
<Set>
<Headers>
<Header name="x-id">{private.id}</Header>
<Header name="x-scopes">Data.Read</Header>
<Header name="x-no-of-rows">12</Header>
</Headers>
<QueryParams>
<QueryParam name="from-date">{fromDate}</QueryParam>
<QueryParam name="to-date">{toDate}</QueryParam>
</QueryParams>
<Verb>GET</Verb>
<Path>/</Path>
</Set>
<AssignTo createNew="true" transport="http" type="request">lambdaRequest</AssignTo>
</AssignMessage>
Solved! Go to Solution.
That's strange. When I try it on my Apigee X instance, it works as I would expect: AssignMessage sets headers, the Java callout sets additional headers and signs things (including the original headers), and ... the target gets all of the headers.
For my test proxy, I used an "echo" target , which just echo's back what it receives. In the response I can see that the target has received all the headers.
$ curl -i $endpoint/muthu-20230919/t1
HTTP/2 200
version: 20230113-1204
content-type: application/json; charset=utf-8
etag: W/"365-ruPUZhM1ePIvc+0zfzEUEMc6O00"
x-cloud-trace-context: b9baabc0a526e23dc78dfa9a19a00d73
date: Tue, 19 Sep 2023 16:38:38 GMT
content-length: 869
apiproxy: muthu-20230919 r1
x-request-id: 24e6fee8-330e-492b-a7d4-d8f698a2cdd4
via: 1.1 google
alt-svc: h3=":443"; ma=2592000,h3-29=":443"; ma=2592000
{
"url": "/t1?from-date=10-08-2023&to-date=15-08-2023",
"method": "GET",
"headers": {
"host": "example.demo.altostrat.com",
"x-id": "123456",
"x-scopes": "Data.Read",
"x-no-of-rows": "12",
"x-amz-date": "20230919T163838Z",
"authorization": "AWS4-HMAC-SHA256 Credential=xWxTestKeyxWx/20230919/ap-south-1/lambda/aws4_request, SignedHeaders=host;x-amz-date;x-id;x-no-of-rows;x-scopes, Signature=20ee3afde9222f4f4cef8cc1c5f215eaadb571b05907d82c397dfbc7b609b139",
"x-cloud-trace-context": "b9baabc0a526e23dc78dfa9a19a00d73/14516245761368739297",
"traceparent": "00-b9baabc0a526e23dc78dfa9a19a00d73-c974109c0ea74de1-00",
"x-forwarded-for": "0.0.0.0",
"x-forwarded-proto": "https",
"forwarded": "for=\"0.0.0.0\";proto=https"
},
"query": {
"from-date": "10-08-2023",
"to-date": "15-08-2023"
},
"body": {}
}%
Attached please find my test proxy. You will need to configure your own echo service in the target.