title: fetch returns 400 bad request
body: <p>I'm trying to make a fetch request to my own server. Error 500 is ideally what I want, because that means the request was successfully sent to the server and my server-side code isn't implemented, so I expect there to be a HTTP 500 response.</p>
  
  <p>However, when I put in another variable, it then returns error 400, which means the request was poorly-formed, so it didn't even make it to the server, I guess?</p>
  
  <p>I don't get why changing the variables would cause the browser to say the request was poorly-formed (400).</p>
  
  <p>Returns Error 500:</p>
  
  <pre><code>fetch("http://example.com/webpush/save_information", {"credentials":"include","headers":{"accept":"*/*","accept-language":"en-US,en;q=0.9","alexatoolbar-alx_ns_ph":"AlexaToolbar/alx-4.0.3","cache-control":"no-cache","pragma":"no-cache"},"referrer":"http://example.com/","referrerPolicy":"no-referrer-when-downgrade","body":JSON.stringify({'test':'1'}),"method":"POST","mode":"cors"});
  </code></pre>
  
  <p>Returns Error 400:</p>
  
  <pre><code>fetch("http://example.com/webpush/save_information", {"credentials":"include","headers":{"accept":"*/*","accept-language":"en-US,en;q=0.9","alexatoolbar-alx_ns_ph":"AlexaToolbar/alx-4.0.3","cache-control":"no-cache","pragma":"no-cache"},"referrer":"http://example.com/","referrerPolicy":"no-referrer-when-downgrade","body":JSON.stringify({'browser':'chrome'}),"method":"POST","mode":"cors"});
  </code></pre>
  
  <p>Can anyone spot a difference?</p>
  
  <p>Edit:</p>
  
  <p>Apparently, it is server-side generated based on the comments, so I'm adding information to my question. I went ahead and grabbed the full fetch and full curl from my console of the request returning error 400:</p>
  
  <pre><code>curl 'https://example.com/webpush/save_information' -H 'origin: https://example.com' -H 'accept-encoding: gzip, deflate, br' -H 'accept-language: en-US,en;q=0.9' -H 'alexatoolbar-alx_ns_ph: AlexaToolbar/alx-4.0.3' -H 'cookie: __cfduid=d558e24311af0551aa5e71c5182a5973c1543351195; _ga=GA1.2.252947937.1543425255; _gid=GA1.2.1592442174.1550785627; gsScrollPos-4659=0; gsScrollPos-4711=; gsScrollPos-4678=' -H 'pragma: no-cache' -H 'user-agent: Mozilla/5.0 (Macintosh; Intel Mac OS X 10_14_2) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/71.0.3578.98 Safari/537.36' -H 'content-type: application/json' -H 'accept: */*' -H 'cache-control: no-cache' -H 'authority: example.com' -H 'referer: https://example.com/' --data-binary '{"status_type":"subscribe","subscription":{"endpoint":"https://fcm.googleapis.com/fcm/send/fiGP6rOnDwE:APA91bEYi2Oydq9c5zMug2QeZK3VDd089-7-YylSnUFqpqc3WlFrZT2tkejzROplb0SHCMA2Tc9Xq0ujhpUa3S-8yWpONgNJ4tFEkyy0m3jcvi3BP2FtNp6_pbdgtLP2nwbuDjkHpc8r","expirationTime":null,"keys":{"p256dh":"BGSJ9xrSKmkTKXjMGYfFAWZ2c_Cj44QJ1k5HkvsDPF-8iphCdQAaSS_ob3G7MOSzsEO-L7fUVs7US21MfuBV-4c","auth":"v8RL7EgDnBlSXnvT7PhvVw"}},"browser":"chrome"}' --compressed
  
  fetch("https://example.com/webpush/save_information", {"credentials":"include","headers":{"accept":"*/*","accept-language":"en-US,en;q=0.9","alexatoolbar-alx_ns_ph":"AlexaToolbar/alx-4.0.3","cache-control":"no-cache","content-type":"application/json","pragma":"no-cache"},"referrer":"https://example.com/","referrerPolicy":"no-referrer-when-downgrade","body":"{\"status_type\":\"subscribe\",\"subscription\":{\"endpoint\":\"https://fcm.googleapis.com/fcm/send/fiGP6rOnDwE:APA91bEYi2Oydq9c5zMug2QeZK3VDd089-7-YylSnUFqpqc3WlFrZT2tkejzROplb0SHCMA2Tc9Xq0ujhpUa3S-8yWpONgNJ4tFEkyy0m3jcvi3BP2FtNp6_pbdgtLP2nwbuDjkHpc8r\",\"expirationTime\":null,\"keys\":{\"p256dh\":\"BGSJ9xrSKmkTKXjMGYfFAWZ2c_Cj44QJ1k5HkvsDPF-8iphCdQAaSS_ob3G7MOSzsEO-L7fUVs7US21MfuBV-4c\",\"auth\":\"v8RL7EgDnBlSXnvT7PhvVw\"}},\"browser\":\"chrome\"}","method":"POST","mode":"cors"});
  </code></pre>
  
  <p>This is for the client-side implementation portion of <a href="https://www.digitalocean.com/community/tutorials/how-to-send-web-push-notifications-from-django-applications" rel="nofollow noreferrer">this tutorial</a>.</p>
  
  <p>Does anything look ill-formed?</p>