Post

3 followers Follow
0
Avatar

Api getAvailability

Hello,

I would like to have code example using AeroCRS getAvailability feature: https://api.aerocrs.com/v5/getAvailability.

 

Regards

Bienfait MBAVU Answered

Official comment

Avatar

Hello Beinfait,

All of our APIs and examples can be found at https://docs.aerocrs.com/
You can find the example for getAvailability request at https://docs.aerocrs.com/reference#getavailablity

In order to find results, use your supplied AeroCRS credentials, and change the dates in the future.
In regards to the example, I would also remove the "fltnum" filter and use only the destinations as set in the example.

Don't have credentials yet?
Kindly fill this form: https://docs.aerocrs.com/docs/sign-up or contact AeroCRS.

Regards,

Eldad Corem
Web Development Team Leader

Eldad Corem
Comment actions Permalink

Please sign in to leave a comment.

6 comments

0
Avatar

Hi,

Thanks for reply.

I tried code example  and got this error:
{"aerocrs":{"success":false,"details":{"detail":[ "Unsupported Media Type"]}}} 

Regards

Bienfait MBAVU 0 votes
Comment actions Permalink
1
Avatar

Hi Bienfait,

 

Please make sure that you add the content-type param to your request:

Content-Type:application/json

Tomer Horviz 1 vote
Comment actions Permalink
0
Avatar

Hi Tomer,

As you suggested, I added content-type param in request. Now I have this error message:

{"aerocrs":{"success":false,"error_type":"request","details":{"detail":"Missing required request parameter: [start], [end]","errorCode":10}}}

 

This is my code:

<?php
//Building the XML:
$xml = new SimpleXMLElement('<aerocrs/>');
$params = $xml->addChild('parms');

$params->addChild("fltnum","M1234");

$dest=$params->addChild('destinations');
$dest->addChild('from','DAR');
$dest->addChild('to','CDG');

$dates=$params->addChild('dates');
$dates->addChild('start','2020/06/11');
$dates->addChild('end','2020/12/30');

//Preparing the POST using cURL
$postString=($xml->asXML());
//Base url '/' method name, case sensitive
$url = 'https://api.aerocrs.com/v5/getAvailability';
$ch = curl_init();
curl_setopt($ch, CURLOPT_URL, $url);
curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_ANY);
curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, false);
curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_SSLVERSION,1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postString);
curl_setopt($ch, CURLOPT_HTTPHEADER, array(
'Content-type: application/json',
'Content-length: ' . strlen($postString),
'auth_id: <MY_ID>',
'auth_password: <MY_PWD>'
));
$response = curl_exec($ch);
curl_close($ch);

echo $response;
?>

 

Bienfait MBAVU 0 votes
Comment actions Permalink
0
Avatar

Hi,

Please note that you are using XML and not JSON for your code so the content type param should be sent correctly.

Tomer Horviz 0 votes
Comment actions Permalink