Problem:
I am using phpCurl to access the API. I tried to update an existing host and while I receive a HTTP 200 response the host info does not get updated.
$url = "http://myserver.domain/api/hosts/$hostid";
$data = array("name" => $hostname, "host" => array("name" => $hostname, "mac"=> $hostmac));
$json = json_encode($data);
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_USERPWD, "myuser:mypass");
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, false);
curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "PUT");
curl_setopt($ch, CURLOPT_PUT, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $json);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-Type: application/json; charset=utf-8',
'Content-Length: ' . strlen($json),
'Cache-Control: no-cache',
'X-Requested-With: XMLHttpRequest',
'X-HTTP-Method-Override: PUT',
));
$result = curl_exec($ch);