skyscanner-python-sdk icon indicating copy to clipboard operation
skyscanner-python-sdk copied to clipboard

carhire_service.get_result(...) Missing data

Open davidch413 opened this issue 8 years ago • 1 comments

I have reused the example from the documentation but every time I make a request I receive a response without submitted_query, images and car_classes lists. I'm using python 3.4.6

`from skyscanner.skyscanner import CarHire

carhire_service = CarHire('my_api_key')

result = carhire_service.get_result( market='UK', currency='GBP', locale='en-GB', pickupplace='27544008', dropoffplace='27544008', pickupdatetime='2017-04-18T10:00', dropoffdatetime='2017-04-25T10:00', driverage='21', userip='127.0.0.1').parsed

print(result) `

davidch413 avatar Apr 11 '17 15:04 davidch413

I found out what the issue is. The documentation says:

... supplying &deltaExcludeWebsites= removes all images, the query, and the car classes lookup. The Location header in the first poll will include this parameter, even if it’s an empty string, in order that you don’t fetch that information multiple times.

To fix it, I have overwritten the create_session method and added

poll_path = poll_path.split('&deltaExcludeWebsites', 1)[0]

This removes &deltaExcludeWebsites from the poll_path allowing images, car classes and query to be returned.

A better way would be saving the data from initial request and merging it with data from the final poll. I will try that approach once I have some spare time.

davidch413 avatar Apr 24 '17 13:04 davidch413