Stevan Tosic
Stevan Tosic

Reputation: 7199

The provided route key is not formatted properly for HTTP protocol

An error occurred: HttpApiRoutePostv1Banks - The provided route key is not formatted properly for HTTP protocol. Format should be "[HTTP METHOD] /[RESOURCE PATH]" or "$default" (Service: AmazonApiGatewayV2; Status Code: 400; Error Code: BadRequestException; Request ID: 38370b30-9c11-4a66-9f2d-710fd2c25329; Proxy: null).

provider:
  ...
  httpApi:
    payload: '2.0' # Define Http format needed for API GW
  ...
functions:
  banksCreate:
    handler: src/banks.create
    events:
      - httpApi: 'POST v1/banks'

I had set up serverless.yml file according to the official documentation

when I run serverless offline everything working fine, but when I try to deploy error above occurs.

I am not sure where I make a mistake?

note that deployment was ok with restApi event

Upvotes: 5

Views: 3527

Answers (1)

Stevan Tosic
Stevan Tosic

Reputation: 7199

NOTE: error message says [HTTP METHOD] /[RESOURCE PATH] which means that / should at path start and path be separated by blank space.

provider:
  ...
  httpApi:
    payload: '2.0' # Define Http format needed for API GW
  ...
functions:
  banksCreate:
    handler: src/banks.create
    events:
      - httpApi: 'POST /v1/banks'

Upvotes: 7

Related Questions