4

I am trying to get location header from the response on POST create session, but getting 405 error. All other response I am getting except for the location header.

require_once 'vendor/autoload.php';
require_once 'vendor/mashape/unirest-php/src/Unirest.php';

$response = Unirest\Request::post("https://skyscanner-skyscanner-flight-search-v1.p.rapidapi.com/apiservices/pricing/v1.0",
  array(
    "X-RapidAPI-Host" => "skyscanner-skyscanner-flight-search-v1.p.rapidapi.com",
    "X-RapidAPI-Key" => "d0f49284f7mshba8a904a96cf3acp19aa44jsnb4056f027c69",
    "Content-Type" => "application/x-www-form-urlencoded"
  ),
  array(
    "inboundDate" => "2019-04-25",
    "cabinClass" => "business",
    "children" => 0,
    "infants" => 0,
    "country" => "IN",
    "currency" => "INR",
    "locale" => "en-US",
    "originPlace" => "BLR-sky",
    "destinationPlace" => "DEL-sky",
    "outboundDate" => "2019-04-26",
    "adults" => 1
  )
);

 print_r($response);

I expect this type of response:

"cache-control": "private"
"content-type": "application/json"
"date": "Wed, 24 Apr 2019 05:01:39 GMT"
"location": "http://partners.api.skyscanner.net/apiservices/pricing/hk1/v1.0/42ba47f0-314c-41fa-987d-fb8c5862309b"
"server": "RapidAPI-1.0.15"
"x-rapidapi-region": "AWS - ap-southeast-1"
"x-rapidapi-version": "1.0.15"
"content-length": "2"
"connection": "Close"

But, actual output is:

Unirest\Response Object ( [code] => 405 [raw_body] => {} [body] => stdClass Object ( ) [headers] => Array ( [0] => HTTP/1.1 405 Method Not Allowed [Cache-Control] => private [Content-Type] => application/json [Date] => Wed, 24 Apr 2019 04:34:14 GMT [Server] => RapidAPI-1.0.15 [X-RapidAPI-Region] => AWS - ap-southeast-1 [X-RapidAPI-Version] => 1.0.15 [Content-Length] => 2 [Connection] => keep-alive ) )

Grokify
  • 15,092
  • 6
  • 60
  • 81
  • 1
    I have the same issue. Did you find a solution for this? – Mark May 23 '19 at 23:54
  • 1
    Look at what the error exactly says: `HTTP/1.1 405` **`Method Not Allowed`**, so that is, for whatever reason, purposely denied. If you believe it's an error, then you should contact Skyscanner. – Tox Sep 19 '19 at 17:02

1 Answers1

0

I'm assuming you're using Skyscanner Flight Search API on RapidAPI Hub. Interestingly enough, I can't see any POST request supported by this API.

This can be the reason, 405 Method Not Allowed means that the HTTP method is simply not supported. For example, a client might do a POST request on a resource where POST is not implemented or it's meaningless.

Pratham
  • 497
  • 3
  • 7