title: HTTP PUT request in Python using JSON data
body: <p>I want to make PUT request in Python using JSON data as </p>
  
  <pre><code>data = [{"$TestKey": 4},{"$TestKey": 5}]
  </code></pre>
  
  <p>Is there any way to do this?</p>
  
  <pre><code>import requests
  import json
  
  url = 'http://localhost:6061/data/'
  
  data = '[{"$key": 8},{"$key": 7}]'
  
  headers = {"Content-Type": "application/json"}
  
  response = requests.put(url, data=json.dumps(data), headers=headers)
  
  res = response.json()
  
  print(res)
  </code></pre>
  
  <p>Getting this error</p>
  
  <p><code>requests.exceptions.InvalidHeader: Value for header {data: [{'$key': 4}, {'$key': 5}]} must be of type str or bytes, not &lt;class 'list'&gt;</code></p>