title: How to properly do an AWS Lambda API Post Request with JSON file using Python
body: <p>I wanted to confirm/see if there is a better way to be making a post request to an API endpoint that was generated for an AWS Lambda? Simply I'm trying to optimize this curl without using a subprocess call. With this code I get an error status code of 400.</p>
  
  <p><strong>Code I'm trying to optimize</strong></p>
  
  <pre><code>$ curl -X POST -d @test.json -H "x-api-key: {API_KEY}" {URL}
  </code></pre>
  
  <p><strong>Python script I've created:</strong></p>
  
  <pre class="lang-py prettyprint-override"><code>import requests
  
  URL = "some_url"
  API_KEY = "some_api_key"
  
  headers = {'x-api-key': API_KEY}
  r = requests.post(URL, headers=headers, json=test.json)
  print(r.status_code)
  print(r.json())
  </code></pre>
  
  <h3>Error Message</h3>
  
  <pre class="lang-none prettyprint-override"><code>raise JSONDecodeError("Expecting value", s, err.value) from None
  json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)
  </code></pre>