Answer the question
In order to leave comments, you need to log in
Can't send PUT data to API using Curl method. How to implement?
It is necessary to send the data using the PUT method. I wrote this script. It seems there are no errors, but the record is not added. Tell me where is the mistake?
// логин и пароль
$server = "https://site/api/task/64651";
$login = "...";
$password = ".";
$params = array(
'Comment' => '1',
'IsPrivateComment' => '1'
);
$paramsdata = json_encode($params);
// авторизация
$ch = curl_init();
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
curl_setopt($ch, CURLOPT_USERPWD, $login . ":" . $password);
// Отправляю
curl_setopt($ch, CURLOPT_URL,"$server");
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/json','Content-Length: ' . strlen($paramsdata)));
curl_setopt($ch, CURLOPT_PUT, true);
//отправляю
curl_exec ($ch);
curl_close ($ch);
Answer the question
In order to leave comments, you need to log in
How to transfer data? I don't understand Curl at all... Dear pros, help me)
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question