title: Preventing Python requests.post to encode strings to UTF-8
body: <p>I am making an API call to an appliance, passing a message in a JSON payload via HTTP POST.</p>
  <p>Despite not doing any character encoding, the string received is encoded in UTF-8.</p>
  <p>Unfortunately, the appliance manufacturer requires no encoding for the message, and characters with accents are turned into 5-character codes :(</p>
  <p>Here is the code:</p>
  <pre><code>import requests
  
  payload = {
             &quot;type&quot;: &quot;send-message&quot;,
             &quot;username&quot;: &quot;myuser&quot;,
             &quot;password&quot;: &quot;mypass&quot;,
             &quot;to&quot;: &quot;456&quot;,
             &quot;msg&quot;: &quot;here are accents: é ç&quot;
            }
  
  resp = requests.post(&quot;http://192.168.1.10/send_message.html&quot;,json=payload)
  </code></pre>
  <p>The result seen by the recipient doesn't show the accent characters correctly:</p>
  <p><a href="https://i.stack.imgur.com/f3cHl.png" rel="nofollow noreferrer">received message</a></p>
  <p>Doing a tcpdump, I can see the HTTP POST made by requests.post contains the following payload:</p>
  <pre><code>{&quot;type&quot;: &quot;send-message&quot;, &quot;username&quot;: &quot;myuser&quot;, &quot;password&quot;: &quot;mypass&quot;, &quot;to&quot;: &quot;456&quot;, &quot;msg&quot;: &quot;here are accents: \u00e9 \u00e7&quot;}
  </code></pre>
  <p>As you can see, the text has been encoded to UTF-8, which is not asked for anywhere in the code.</p>
  <p>If I try to force decode  <code>&quot;here are accents: é ç&quot;.decode('utf-8')</code> I get the error <code>AttributeError: 'str' object has no attribute 'decode'</code> which makes sense because it's not encoded.</p>
  <p>If I attempt to force ASCII: <code>&quot;here are accents: é ç&quot;.encode('ascii','ignore')</code> then the accents will be lost.</p>
  <p>Testing <strong>with CURL it works perfectly</strong>:</p>
  <p><code>curl -X POST 'http://192.168.1.10/send_message.html' -H 'Content-Type: application/json' -d '{&quot;type&quot;: &quot;send-message&quot;,&quot;username&quot;: &quot;myuser&quot;,&quot;password&quot;: &quot;mypass&quot;,&quot;to&quot;: &quot;456&quot;,&quot;msg&quot;: &quot;here are accents: é ç&quot; }' </code></p>
  <p>Looking at the tcpdump with the curl attempt from the linux CLI shows the JSON exactly as sent, and the appliance recognizes the accents and sends them exactly as expected.</p>
  <p>Imported into Wireshark, the string sent by CURL which is not UTF-8 formatted, and is correctly interpreted looks like this:</p>
  <p><a href="https://i.stack.imgur.com/vOcXq.png" rel="nofollow noreferrer">wireshark-screenshot</a></p>
  <p>Is there a way to tell Python's requests.post NOT to translate to UTF-8, or do I have to re-code the HTTP POST?</p>
  <p>Thank you so much in advance.</p>