title: Why is PHP cURL PUT request not working despite getting status code 200 in return?
body: <p>I've been stuck with this problem for a little while now. I am trying to use a REST API to change certain settings of a user like clear a user and set their device to inactive. </p>
  
  <p>The REST calls are made in php which I am pretty new to. Most calls (get and post) are working just fine so I think I understood the basic concept of php and curl but I just can't get put requests working. The problem is that when making the REST call I get a status code 200 in return indicating that everything went fine but when I check the database nothing changed and the device is still active. </p>
  
  <p>I've spent several hours researching this problem here on stackexchange (<a href="https://stackoverflow.com/questions/41947205/curl-put-request-not-working-with-php">cURL PUT Request Not Working with PHP</a>, <a href="https://stackoverflow.com/questions/28925567/php-curl-return-200-but-not-posting">Php Curl return 200 but not posting</a>, <a href="https://stackoverflow.com/questions/37585513/php-curl-put-function-not-working">PHP CURL PUT function not working</a>) and additionally reading various tutorials. 
  To me my code looks fine and makes perfect sense because it is similar to many examples I found online. So please help me find my mistake.</p>
  
  <pre><code>$sn = "123456789";
  $ch = curl_init();
  curl_setopt($ch, CURLOPT_URL, "https://example.com/api/sn/".$sn);
  
  $data = array("cmd" =&gt; "clearUser");
  $headers = array(
      'Accept: application/json',
      'Content-Type: application/json'
  );
  curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
  
  curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
  $username = 'XXX';
  $password = 'XXX';
  curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
  curl_setopt($ch, CURLOPT_USERPWD, "$username:$password");
  curl_setopt($ch, CURLOPT_HEADER, 0);
  curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
  curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
  curl_setopt($ch, CURLOPT_POSTFIELDS,http_build_query($data));
  
  $output = curl_exec($ch);
  curl_close($ch);
  </code></pre>