# BadRequestException when having API gateway call BatchPutItem in DynamoDB directly

**URL:** <https://forum.serverless.com/t/badrequestexception-when-having-api-gateway-call-batchputitem-in-dynamodb-directly/15976>\
**Category:** Event Gateway\
**Tags:** aws, api-gateway, dynamodb\
**Created:** [September 25, 2021, 11:42pm UTC](https://forum.serverless.com/t/badrequestexception-when-having-api-gateway-call-batchputitem-in-dynamodb-directly/15976 "2021-09-25T23:42:10Z")\
**Posts on this page:** 1\
**Page:** 1

<div class="post-metadata">

**Author:** ![jblack975](https://yyz2.discourse-cdn.com/flex036/user_avatar/forum.serverless.com/jblack975/32/6219_2.png) [@jblack975](https://forum.serverless.com/u/jblack975)\
**Post date:** [September 25, 2021, 11:42pm UTC](https://forum.serverless.com/t/badrequestexception-when-having-api-gateway-call-batchputitem-in-dynamodb-directly/15976/1 "2021-09-25T23:42:10Z")

</div>

I have a yml file that works flawlessly to provision an identity pool, user pool and cognito.

I want to have where I can call an API service and have it put that data directly into DynamoDB without a lambda.

I get this error:

> An error occurred: EventsDeployment - The REST API doesn’t contain any methods (Service: AmazonApiGateway; Status Code: 400; Error Code: BadRequestException; Request ID: bdee0426-532e-43f1-b2dd-76fa463eff0c; Proxy: null).

This happens whenever I use this block of code in my file. I am thinking the uri may be the cause, but I am not certain.

I am not certain what I did wrong.

I am using frameworkVersion: ‘2’ and I don’t know if that is my issue.

> EventsDeployment:  
> Type: AWS::ApiGateway::Deployment  
> Properties:  
> RestApiId:  
> Ref: ApiGatewayRestApi  
> StageName: ${self:provider.stage}  
> EventsAPI:  
> Type: AWS::ApiGateway::Method  
> Properties:  
> RestApiId:  
> Ref: ApiGatewayRestApi  
> ResourceId:  
> Ref: EventsResource  
> OperationName: ‘AddEvents’  
> AuthorizerId:  
> Ref: APIAuthorizer  
> AuthorizationType: COGNITO\_USER\_POOLS  
> HttpMethod: POST  
> Integration:  
> Type: AWS  
> IntegrationHttpMethod: POST  
> Uri: arn:aws:apigateway:us-east-1:dynamodb:action/BatchWriteItem  
> Credentials:  
> Fn::GetAtt: [ApiGatewayDynamoRole, Arn]  
> PassthroughBehavior: NEVER  
> RequestTemplates:  
> application/json: |  
> #set($inputRoot = $input.path(‘$’))  
> {  
> “RequestItems”: {  
> “${self:resources.Resources.EventsTable.Properties.TableName}”: [  
> #foreach($event in $inputRoot.event)  
> {  
> “PutRequest”: {  
> “Item”: {  
> “UserID” : { “S”: “$context.authorizer.claims.sub” },  
> “TimeUTC” : { “S”: “$event.time” },  
> “Lat”: { “N”: “$event.lat” },  
> “Lng”: { “N”: “$event.lng” },  
> “UUID” : { “S”: “$event.uuid”},  
> “Sensor” : { “S”: “$event.sensor\_name” },  
> “Reading” : { “N”: “$event.reading\_value” },  
> “Active” : { “BOOL”: “$event.is\_active” },  
> }  
> }  
> }#if($foreach.hasNext),#end  
> #end  
> ]  
> },  
> “ReturnConsumedCapacity”: “NONE”,  
> “ReturnItemCollectionMetrics”: “NONE”  
> }  
> IntegrationResponses:  
> - StatusCode: ‘200’  
> SelectionPattern: “2\d{2}”  
> ResponseParameters:  
> method.response.header.Access-Control-Allow-Origin: “‘_‘"  
> ResponseTemplates:  
> application/json: ‘{}’  
> - StatusCode: ‘400’  
> SelectionPattern: “4\d{2}”  
> ResponseParameters:  
> method.response.header.Access-Control-Allow-Origin: "’_’”  
> MethodResponses:  
> - StatusCode: ‘200’  
> ResponseParameters:  
> method.response.header.Access-Control-Allow-Origin: true  
> ResponseModels:  
> application/json: Empty  
> - StatusCode: ‘400’  
> ResponseParameters:  
> method.response.header.Access-Control-Allow-Origin: true  
> ResponseModels:  
> application/json: Error
