SportScore

GRATIS CON POSSIBILITÀ DI UPGRADE
Verified
Da Tipsters CO | Aggiornamento 2ヶ月前 | Sports
Popolarità

9.9 / 10

Latenza

84ms

Livello di servizio

100%

Torna a tutte le discussioni

POST request not working

Rapid account: Cedk
cedk
10ヶ月前

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 10ヶ月前

ok!

Rapid account: Cedk
cedk Commented 10ヶ月前

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);


Partecipa alla discussione - aggiungi un commento di seguito:

Accedi/Iscriviti per pubblicare nuovi commenti
Valutazione: 4.3 - Voti: 7