Я хочу получить доступ к api с моим правильным ключом api, но все еще получаю ошибку 401 unauthorized. Api с использованием json rp c 2.0.
Это пример запроса из api docs.
Request:
{
"jsonrpc": "2.0",
"method": "getBoards",
"params": {
"clientId": "apikey"
},
"id": 1
}
А это мой php код.
$apiKey = 'apikey';
$apiUrl = 'apiUrl';
$data = array(
"jsonrpc" => "2.0",
"method" => "getBoards",
"params" => array(
"clientId" => $apiKey
),
"id" => "1"
);
$data_string = json_encode($data);
$ch = curl_init($apiUrl);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLINFO_HEADER_OUT, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $data_string);
$response = curl_exec($ch);
curl_close($ch);
print_r($response);