title: Configure sam local start-api to send PUT request payloads only
body: <p><em>My main question is:</em><br />
  <strong>How can I configure SAM to create API endpoints without Lambda Proxy Integration?</strong></p>
  <p><em>Details:</em><br />
  I am trying to test an API Gateway + Lambda deployment locally. The Lambda function I have specified is expecting to receive the payload of <code>PUT</code> requests on <code>/some-endpoint</code> as the <code>event</code> when invoked. This is the behavior on AWS when creating this endpoint without Lambda Proxy Integration.</p>
  <p>However, it seems that <code>sam local start-api</code> defaults to using Proxy Integration; obviously, this results in an <code>event</code> with unexpected structure for my Lambda. I just tried changing the method to GET, and still see Proxy Integration behavior, so it's not PUT-specific.</p>
  <p>I know that the local API Gateway and Lambda are communicating and that my function is otherwise working as I want when I test Lambda with <code>sam local invoke -e sample-payload.json</code>.</p>
  <p>I haven't tried <code>sam deploy</code> to know if this is unique to <code>sam local</code> or the general behavior of SAM-specified endpoints.</p>
  <p><strong>Clarification:</strong> <code>sam local</code> and my Lambda code are functioning, no errors aside from those arising from the unexpected <code>event</code> format due to <code>sam</code> defaulting to Lambda Proxy Integration. The SAM documentation says nothing about configuring the PUT method handling, but maybe someone here can help.</p>
  <p>Roughly, my Lambda function (event) is expecting <code>event</code> to be the JSON payload of PUT requests, eg</p>
  <pre class="lang-py prettyprint-override"><code>{&quot;id&quot;: &quot;user123&quot;}
  </code></pre>
  <p>If I use the AWS console to set up the API Gateway <code>/some-endpoint</code> resource's PUT method, and <em>do not make this endpoint with Lambda Proxy Integration</em> then API Gateway passes along just the body/payload, as above.</p>
  <p>When I use <code>sam local start-api</code> based on the YAML above, then send a PUT to <code>http://localhost:3000/some-endpoint</code>, the request makes it to my Lambda function just fine, but I get the <code>event</code> is now formatted as Proxy Integration. So, <code>event</code> now looks like</p>
  <pre class="lang-py prettyprint-override"><code>{&quot;body&quot;: '{&quot;id&quot;: &quot;abc123&quot;}', &quot;httpMethod&quot;: &quot;GET&quot;, ...}
  </code></pre>
  <p>and I have to parse the <code>&quot;body&quot;</code> to get the payload I want.</p>
  <p>Ultimately I could change the code to expect Proxy Integration instead, but ideally <code>sam local start-api</code> could send just payloads.</p>
  <hr />
  <p>For a minimal example of this:</p>
  <p><strong>Lambda Python 3.8 script</strong> returning the event for illustration.</p>
  <p><code>my_function.py</code></p>
  <pre class="lang-py prettyprint-override"><code>import json
  
  
  def handler(event, context):
      return {
          &quot;statusCode&quot;: 200,
          &quot;body&quot;: json.dumps(event)
      }
  </code></pre>
  <p>SAM file, <code>template.yml</code></p>
  <pre><code>AWSTemplateFormatVersion: '2010-09-09'
  Transform: AWS::Serverless-2016-10-31
  
  Resources:
    MyFunction:
      Type: 'AWS::Serverless::Function'
      Properties:
        Handler: my_function.handler
        Runtime: python3.8
        CodeUri: .
        Policies: AWSLambdaBasicExecutionRole
        Description: ''
        MemorySize: 128
        Timeout: 3
        Role: 
        Events:
          Api1:
            Type: Api
            Properties:
              Path: /some-endpoint
              Method: PUT
  </code></pre>
  <p>And a payload to PUT.<br />
  <code>id-event.json</code></p>
  <pre><code>{&quot;id&quot;: &quot;user123&quot;}
  </code></pre>
  <p>What I'm looking for is the response of a PUT to <code>localhost:3000/some-endpoint</code> to be <code>{&quot;id&quot;: &quot;user123&quot;}</code>.</p>