title: KeyError: 'requestContext', FastAPI, Mangum, Serverless
body: <p>I am trying to use Serverless Framework to deploy a Python Fast API WebApp.
  Is is related to issue:</p>
  <p><a href="https://github.com/jordaneremieff/mangum/issues/126" rel="nofollow noreferrer">https://github.com/jordaneremieff/mangum/issues/126</a></p>
  <p>When I deploy it using serverless, sls depoy and Invoke the function I am getting the following error:</p>
  <pre><code>[ERROR] KeyError: 'requestContext'
  Traceback (most recent call last):
    File &quot;/var/task/mangum/adapter.py&quot;, line 110, in __call__
      return self.handler(event, context)
    File &quot;/var/task/mangum/adapter.py&quot;, line 130, in handler
      if &quot;eventType&quot; in event[&quot;requestContext&quot;]:
  </code></pre>
  <p>I have tried with python 3.8 and 3.7.
  Not able to find a resolution on the web for the same.
  Also tried using the parameters spec_version=2(which is not required I feel).</p>
  <p>I feel something is missing here, the issue is somewhere around:</p>
  <pre><code>Adapter requires the information in the event and request context to form the ASGI connection scope.
  </code></pre>
  <p>Wondering if anyone has got FastAPI working on AWS Lambda using serverless Framework.</p>
  <p>My handler:</p>
  <pre><code>from fastapi import FastAPI
  from mangum import Mangum
  
  
  app = FastAPI()
  handler = Mangum(app)
  
  @app.get(&quot;/ping&quot;)
  def ping():
      return {'response': 'pong'}
  
  </code></pre>
  <p>serverless.yml:</p>
  <pre><code>provider:
    name: aws
    runtime: python3.8
    stage: dev
    region: ap-southeast-1
    memorySize: 256
  
  functions:
    ping:
      handler: ping.handler
      events:
        - http:
            path: ping
            method: get
            cors: true
  </code></pre>
  <p>My requirements.txt</p>
  <pre><code>appnope==0.1.0
  backcall==0.2.0
  certifi==2020.6.20
  chardet==3.0.4
  click==7.1.2
  decorator==4.4.2
  fastapi==0.61.1
  h11==0.9.0
  httpcore==0.10.2
  httptools==0.1.1
  httpx==0.14.1
  idna==2.10
  ipython==7.17.0
  ipython-genutils==0.2.0
  jedi==0.17.2
  mangum==0.9.2
  parso==0.7.1
  pexpect==4.8.0
  pickleshare==0.7.5
  prompt-toolkit==3.0.6
  ptyprocess==0.6.0
  pydantic==1.6.1
  Pygments==2.6.1
  requests==2.24.0
  rfc3986==1.4.0
  six==1.15.0
  sniffio==1.1.0
  starlette==0.13.6
  traitlets==4.3.3
  typing-extensions==3.7.4.2
  urllib3==1.25.10
  uvicorn==0.11.8
  uvloop==0.14.0
  wcwidth==0.2.5
  websockets==8.1
  </code></pre>