I’m using the cloud offered by rocket.chat.
Hi,
It’s quite strange, I’m trying to create a channel with php, but using this code, the service shows the error:
{“success”:false,“error”:“Param “name” is required”}
It works fine sending it via postman, that’s why I’m saying that’s quite strange.
The code in php is the following:
Regards
$Token = “xxxxxxxxxxx”;
$Id_elemento = “initialuser”;
$url = “https://xxxxxxxxxxx.rocket.chat/api/v1/channels.create”;
$data = array(
‘name’=> ‘Room_test’
);
$content = json_encode($data);
$curl = curl_init($url);
$headr = array();
$headr[] = ‘X-Auth-Token:’.$Token;
$headr[] = ‘X-User-Id:’.$Id_elemento;
curl_setopt($curl, CURLOPT_CUSTOMREQUEST, “POST”);
echo($content);
curl_setopt($curl, CURLOPT_POSTFIELDS, $content);
curl_setopt($curl, CURLOPT_RETURNTRANSFER, true);
curl_setopt($curl, CURLOPT_HTTPHEADER, $headr
);
$json_response = curl_exec($curl);
$response = json_decode($json_response, true);
$status = curl_getinfo($curl, CURLINFO_HTTP_CODE);
curl_close($curl);
$response_aux = ($json_response);
print_r($response_aux);