SportScore

FREEMIUM
Verified
Door Tipsters CO | Bijgewerkt vor 2 Monaten | Sports
Populariteit

9.9 / 10

Latency

80ms

Serviceniveau

100%

Terug naar alle discussies

POST request not working

Rapid account: Cedk
cedk
vor 10 Monaten

Hi, today the POST request /teams/search?sport_id=3&country=France is not working (using CURL in PHP).

I don’t understand why the response is a HTTP/1.1 400 Bad Request.


Trying 3.226.33.234:443…

  • Connected to sportscore1.p.rapidapi.com (3.226.33.234) port 443 (#0)
  • ALPN, offering http/1.1
  • SSL connection using TLSv1.2 / ECDHE-RSA-AES128-GCM-SHA256
  • ALPN, server accepted to use http/1.1
  • Server certificate:
  • subject: CN=*.p.rapidapi.com
  • start date: Jul 6 00:00:00 2022 GMT
  • expire date: Aug 4 23:59:59 2023 GMT
  • subjectAltName: host “sportscore1.p.rapidapi.com” matched cert’s “*.p.rapidapi.com”
  • issuer: C=US; O=Amazon; OU=Server CA 1B; CN=Amazon
  • SSL certificate verify ok.

POST /teams/search?sport_id=3&country=France HTTP/1.1
Host: sportscore1.p.rapidapi.com
Accept: /
Accept-Encoding: deflate, gzip, br
X-RapidAPI-Host: sportscore1.p.rapidapi.com
X-RapidAPI-Key: ****

  • Mark bundle as not supporting multiuse
    < HTTP/1.1 400 Bad Request
    < Date: Wed, 17 Aug 2022 11:10:53 GMT
    < Content-Type: text/plain; charset=UTF-8
    < Transfer-Encoding: chunked
    < Connection: keep-alive
    < X-RateLimit-Requests-Limit: 500
    < X-RateLimit-Requests-Remaining: 301
    < X-RateLimit-Requests-Reset: 187629
    < Server: RapidAPI-1.2.8
    < X-RapidAPI-Version: 1.2.8
    < X-RapidAPI-Region: AWS - us-east-1
    <
  • Connection #0 to host sportscore1.p.rapidapi.com left intact
    string(0) “”
Rapid account: Tipsters
tipsters Commented vor 10 Monaten

ok!

Rapid account: Cedk
cedk Commented vor 10 Monaten

OK I found the problem.

The example code is incorrect, the post data must be passed as a query string in the CURLOPT_POSTFIELDS field, not in the enpoint URL as suggested.

<?php

$curl = curl_init();

$data = [
	'sport_id' => 3,
	'country' => 'France'
];

$post_data = http_build_query($data);

curl_setopt_array($curl, [
	CURLOPT_URL => "https://sportscore1.p.rapidapi.com/players/search",
	CURLOPT_RETURNTRANSFER => true,
	CURLOPT_FOLLOWLOCATION => true,
	CURLOPT_ENCODING => "",
	CURLOPT_MAXREDIRS => 10,
	CURLOPT_TIMEOUT => 30,
	CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
	CURLOPT_CUSTOMREQUEST => "POST",
	CURLOPT_HTTPHEADER => [
		"X-RapidAPI-Host: sportscore1.p.rapidapi.com",
		"X-RapidAPI-Key: ***"
	],
	CURLOPT_POSTFIELDS => $post_data
]);

$response = curl_exec($curl);
$err = curl_error($curl);
$info = curl_getinfo($curl, CURLINFO_HTTP_CODE);

var_dump('info', $info);
var_dump('response', $response);
var_dump('err', $err);

curl_close($curl);


Doe mee aan de discussie - voeg hieronder een opmerking toe

Log in / Schrij u in om nieuwe opmerkingen te plaatsen
Beoordeling: 4.3 - Stemmen: 7