03-27-2020 18:51
03-27-2020 18:51
I have been trying to create new subscriptions via PHP but it always returns a 400 bad request error. I have tried making the command manually and it works, but my php code doesn't work.
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, "https://api.fitbit.com/1/user/-/body/apiSubscriptions/3.json");
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$headers = array();
$headers[] = "Authorization: Bearer $access_token";
$headers[] = "Content-Type: application/x-www-form-urlencoded";
curl_setopt($ch, CURLOPT_HTTPHEADER, $headers);
$result = curl_exec($ch);
if (curl_errno($ch)) {
echo 'Error:'.curl_error($ch);
}
$response_code = curl_getinfo($ch, CURLINFO_HTTP_CODE);
curl_close($ch);
echo $response_code;
}
03-31-2020 15:07
03-31-2020 15:07
Hi @rocketslay1,
Can you provide me with the error message you are seeing? The messaging may help identify what the issue is.
Hope to hear from you soon!
04-01-2020 06:15
04-01-2020 06:15
I am getting a '400 bad request - cloudflare' error.
10-13-2023 12:34
10-13-2023 12:34
I am also getting the same error
<html>
<head><title>400 Bad Request</title></head>
<body>
<center><h1>400 Bad Request</h1></center>
<hr><center>cloudflare</center>
</body>
</html>
Can somebody help here ?