خرید بک لینک

Vote count: 0

Currently using a test developer account for Sabre Dev Studio and trying to use their REST Api - Instaflights_Search.

I'm creating the authentication and getting an access token fine but the problem arises when I try to send a request. I'm creating the headers using curl and php.

function callRestApi($url,$access_token) {

    $ch = curl_init();

    $header = array();
    $header[] = "Authorization: Bearer " .$access_token;
    $header[] = "Accept: application/json";
    $header[] =  'Content-Type: application/json';

    curl_setopt($ch, CURLOPT_URL, $url);
    curl_setopt($ch, CURLOPT_HTTPHEADER, $header);
    curl_setopt($ch, CURLOPT_HTTPGET, 1);
    curl_setopt($ch, CURLOPT_VERBOSE, true);
    curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);

    $result = curl_exec($ch);
    curl_close($ch);
    retu json_decode($result,true);
}


$url = "https://api.test.sabre.com/v1/shop/flights?origin=JFK&destination=LAX&departuredate=2016-05-30&retudate=2016-05-31";

$access_token = callForToken();

$server_response = callRestApi($url,$access_token);

The Sabre response is:

   array(5) {
     ["status"]=>
     string(12) "NotProcessed"
     ["type"]=>
     string(10) "Validation"
     ["errorCode"]=>
     string(30) "ERR.2SG.CLIENT.INVALID_REQUEST"
     ["timeStamp"]=>
     string(29) "2016-05-19T22:36:51.041-05:00"
     ["message"]=>
     string(60) "Request is invalid: The request should have the JSON payload"
    }

And the HTTP 1/1 request header reads as:

* Hostname was found in DNS cache
*   Trying 151.193.52.94...
* Coected to api.test.sabre.com (151.193.52.94) port 443 (#0)
* successfully set certificate verify locations:
*   CAfile: /etc/pki/tls/certs/ca-bundle.crt CApath: none
* SSL coection using TLSv1.2 / AES256-SHA
* Server certificate:
*    subject: C=US; ST=Texas; L=Southlake; O=Sabre, Inc.; OU=Inteet   Services; CN=api.test.sabre.com
*    start date: 2015-02-25 00:00:00 GMT
*    expire date: 2017-03-21 23:59:59 GMT
*    subjectAltName: api.test.sabre.com matched
*    issuer: C=US; O=Symantec Corporation; OU=Symantec Trust Network; CN=Symantec Class 3 Secure Server CA - G4
*    SSL certificate verify ok.
    > GET /v1/shop/flights?origin=JFK&destination=LAX&departuredate=2016-05-30&retudate=2016-05-315&onlineitinerariesonly=n&limit=10&offset=1&eticketsonly=n&sortby=totalfare&order=asc&sortby2=departuretime&order2=asc&pointofsalecountry=US HTTP/1.1
Host: api.test.sabre.com
Authorization: Bearer T1FNEWIhYyxjzQJ/Fh4oPfgkjU4s+R/xAxglSqD2oC4kYcCAnPcIv+bbV9sTu3KHxdpQ+zRKUsTGmpfhQT//Djx+3yDNZUcypKrbjzIzjVJvDPI+PyH5bT4F88Gcse//7hjcrz5sCRXkqwqjb1ceaBhGV2hr0t47XwBcjEvPg2I92FtFsqNw7V8NrcPfBVFxnZAbqESJ+zUQH6mSeaWa1h3Rc04g4szipQhHWDnR+sneH8ePdHKPQaoX3M44YMRvviOV8yEBYwTg**
Accept: application/json
Content-Type: application/json

< HTTP/1.1 400 Bad Request
< Date: Fri, 20 May 2016 03:15:28 GMT
< Content-Type: application/json
< Content-Length: 207
< 
* Coection #0 to host api.test.sabre.com left intact

Any ideas what could be the problem with the header?

asked 53 secs ago

برچسب: نویسنده: استخدام کار تاريخ: جمعه 31 ارديبهشت 1395 ساعت: 11:05

صفحه بندی