3

I'm trying to deploy a lambda function with aws api gateway. I was able to succesfully deploy and test POST and GET methods with Content-Type: application/json by following this blog: http://kennbrodhagen.net/2015/12/06/how-to-create-a-request-object-for-your-lambda-event-from-api-gateway/

I want my same lambda function to handle requests of content-type : text/plain, x-www-form-urlencoded also.

The problem with integration template is that we have to define the content-type before hand. So if I make a integration template of Content-type: text/plain how can I call that integration template when the api request of text/plain is made to the url. How can I invoke different integration templates based on the Content-Type of the api request?

any tips on that?

Thanks.

1 Answer 1

1

I don't know whether I got your problem right r not.

From my understanding if you are passing any header information or query string parameters and the content type is text/plain you can map the template like this

{
    "prod_Id" : "$input.params('prod_Id')"
}

where product id can be the header or query string parameter.

you can find it in my blog in 'how to pass query string section

Sign up to request clarification or add additional context in comments.

2 Comments

What happens to the request if I create two integration mapping templates 1. text/plain 2. application/json. ?
so whatever request you will get from whichever template it will work accordingly

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.