Hi all
I’m learning serverless framework and I would like to know how to send a json object in the body of a PUT request with integration type lambda. Bellow is the object (my language is java, but I guess it doesn’t matter):
public class Product {
private Long id;
private String name;
private Double value;
private String description;
//getters & setters
}
I did try many ways around this in my serverless.yml to map this request correctllly, but no success:
updateProduct:
handler: com.serverless.requests.UpdateProduct
role: arn:aws:iam::42424242424242:role/DBA
environment:
TABLE_NAME: Product
events:
- http:
path: product
method: put
integration: lambda
request:
template:
application/json:
'{
"id": "$input.id",
"name": "$input.params(''name'')",
"value": "$input.params(''value'')",
"description": "$input.params(''description'')"
}'
The lambda function should look like this:
public class UpdateProduct implements RequestHandler<Product, ApiGatewayResponse> {
@Override
public ApiGatewayResponse handleRequest(Product input, Context context) {
...
}
So how can I send the product object in the request body and retrieve it in the lambda function?
thanks