Mapping multiple values for a requestParameter key

0

Hello there,

Is it possible to pass multiple values to a single request parameter key in integration requests? JSON like or encoded string?

A typical use case could be passing the sub property from the authorizer in the SNS message payload, together with other parameters

So far I have tried this:

integration.request.querystring.Message.foo: method.request.path.foo
integration.request.querystring.Message.bar: method.request.path.bar
integration.request.querystring.Message.userId: context.authorizer.claims.sub

But when I make the request via Postman I have this error:

    "Error": {
        "Code": "MalformedInput",
        "Message": "Start of list found where not expected",
        "Type": "Sender"
    },

Is this even possible? The docs do not mention it

teo
gefragt vor 4 Jahren1662 Aufrufe
4 Antworten
0
Akzeptierte Antwort

It's not possible via the parameter mapping but doable within the request body mapping template with request override feature.
https://docs.aws.amazon.com/apigateway/latest/developerguide/apigateway-override-request-response-parameters.html

Please note that the request/response override is only available in REST API.

AWS
beantwortet vor 4 Jahren
0

up please =)

teo
beantwortet vor 4 Jahren
0

Hello, first of all, thank you very much for the response.

And yes it worked by using mapping template, I thought they were only for body.

This is the working solution, under

requestTemplates:
                 application/json:
#set($foo = $input.params('foo'))
#set($userId = $context.authorizer.claims.sub)
$input.json("$")
#set($context.requestOverride.querystring.Message = "{
    ""foo"":  ""$foo"",    
    ""userId"" : ""$userId""
}")"
teo
beantwortet vor 4 Jahren
0

For a mix of numeric and associative arrays one can use this syntax as well:

#set($context.requestOverride.querystring['filter[0][action]'] = "where")
#set($context.requestOverride.querystring['filter[0][attribute]'] = "status")
beantwortet vor 9 Monaten

Du bist nicht angemeldet. Anmelden um eine Antwort zu veröffentlichen.

Eine gute Antwort beantwortet die Frage klar, gibt konstruktives Feedback und fördert die berufliche Weiterentwicklung des Fragenstellers.

Richtlinien für die Beantwortung von Fragen