ashraf Khan
ashraf Khan

Reputation: 21

how to pass and access path parameters in aws api gateway

I am new in web development and trying to learn AWS. I have made a lambda function for listing. What I am doing here is I am showing listing, if I get counteId in params(URL) then it shows only data of that counter id else it shows all data. My lambda function was working fine. But I am having a problem while API integration.

this is how I am accessing pathparameters which are in the event

this is how I am configuring event

and this is my query and response

then I create an API gateway for it. this is what I did while creating Resource

/{proxy+} - ANY - Setup

I want to get only data of counterId 1, but I am getting whole data. response

My HTTPmethod is "ANY" and I choose lambda proxy integration in request integration. I don't know how to send path parameters. Kindly help me.

Upvotes: 2

Views: 3038

Answers (1)

RredCat
RredCat

Reputation: 5431

You have to edit 'Mapping Template' in 'Integration Request' of you method properties in API Gateway.

You could find how to map it in API Gateway Mapping Template Reference article, in the 'Accessing the $input Variable' section.

Your template has to look like next:

{
    "name" : "$input.params('name')",
    "body" : $input.json('$') 
}

Check out more details in my answer to the similar question.

Upvotes: 1

Related Questions