The PUT request shows “HTTP/1.0 406 Not Acceptable: Missing node type” [closed]
-
30-10-2019 - |
Question
I have been trying to update a node data from the PUT request using cURL. bit due to some reason its showing "HTTP/1.0 406 Not Acceptable: Missing node type", I think the request is done proper but the data is not in proper format. Below is my code.
$newSketchBoard = array(
'title' => $title,
'type' => 'rest_sketchboard_user',
'field_sketchboarduser_user_id[und][0][value]'=>$data['uid'],
'field_sketchboard_paintjob_id[und]' => $data['paintjobid'],
'field_sketchboard_template_id[und][0][value]' => $data['templateid'],
'field_sketchboard_user_color_id1[und]' => $data['colorid1'],
'field_sketchboard_user_color_id2[und]' => $data['colorid2'],
'field_sketchboard_user_color_id3[und]' => $data['colorid3'],
'field_sketchboard_user_color_id4[und]' => $data['colorid4'],
);
$entity_id=$sketchboard_data['entity_id'];
$ch = curl_init();
curl_setopt($ch, CURLOPT_HEADER,true);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_TIMEOUT, 600);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1);
curl_setopt($ch, CURLOPT_COOKIE, "{$session_cookie}");
curl_setopt($ch, CURLOPT_PUT, 1);
curl_setopt($ch, CURLOPT_URL, REST_BASE_URL."/node/{$entity_id}");
$putString = $newSketchBoard;
// Put string into a temporary file
$putData = tmpfile();
// Write the string to the temporary file
fwrite($putData, $putString);
// Move back to the beginning of the file
fseek($putData, 0);
curl_setopt($ch, CURLOPT_INFILE, $putData); // file pointer
curl_setopt($ch, CURLOPT_INFILESIZE, strlen($putString));
//curl_setopt($ch, CURLOPT_POSTFIELDS, $newSketchBoard);
$result = curl_exec($ch);
print_r($result);
I also tried using the following code, but it's not working.
$putString = json_encode($newSketchBoard);
$putString = http_build_query($newSketchBoard);
No correct solution
Licensed under: CC-BY-SA with attribution
Not affiliated with drupal.stackexchange