Harman
Harman

Reputation: 1208

OLA API Integration giving error as invalid partner key

I wanted to use OLA APIs for my project. So I followed the official docs of OLA and tried something as follow using python requests. This request expects response for ride estimate from source to destination.

import requests

headers = {'X-APP-TOKEN' : "your_api_token"}
payload= {'pickup_lat': 12.9490936, 'pickup_lng': 77.67773056, 'drop_lat': 12.9190934, 'drop_lng': 77.1777356, 'category': 'micro'}
response = requests.get('https://devapi.olacabs.com/v1/products', params=payload, headers=headers)
print(response.json())

As mentioned in the docs I have included the X-APP-TOKEN in the request header as well. But I'm getting the following issue.

{'code': 'invalid_partner_key', 'message': 'Partner key is not authorized'}

Any help would be highly appreciated.

Upvotes: 4

Views: 1187

Answers (2)

Mandeep Singh Tanwar
Mandeep Singh Tanwar

Reputation: 181

Use

https://sandbox-t1.olacabs.com//v1/products

instead of

https://devapi.olacabs.com//v1/products

while making a ride availability api request.

eg. GET https://sandbox-t1.olacabs.com//v1/products?pickup_lat=12.9491416&pickup_lng=77.64298&category=mini

Headers: [{"key":"X-APP-TOKEN","value":"2e987510441744ceabbbe8b4f9382e93","description":""}]

Response:

{
    "categories": [
        {
            "id": "mini",
            "display_name": "Mini",
            "currency": "INR",
            "distance_unit": "kilometre",
            "time_unit": "minute",
            "eta": -1,
            "distance": -1,
            "ride_later_enabled": "true",
            "image": "http://d1foexe15giopy.cloudfront.net/mini.png",
            "all_cabs": [],
            "cancellation_policy": {
                "cancellation_charge": 50,
                "currency": "INR",
                "cancellation_charge_applies_after_time": 10,
                "time_unit": "minute"
            },
            "fare_breakup": [
                {
                    "type": "flat_rate",
                    "minimum_distance": 5,
                    "minimum_time": 1,
                    "base_fare": "150.0",
                    "minimum_fare": "180.0",
                    "cost_per_distance": "37.5",
                    "waiting_cost_per_minute": 0,
                    "ride_cost_per_minute": "9.0",
                    "surcharge": [],
                    "rates_lower_than_usual": false,
                    "rates_higher_than_usual": true
                },
                {
                    "type": "flat_rate",
                    "minimum_distance": 5,
                    "minimum_time": 1,
                    "base_fare": "135.0",
                    "minimum_fare": "166.5",
                    "cost_per_distance": "33.0",
                    "waiting_cost_per_minute": 0,
                    "ride_cost_per_minute": "9.0",
                    "surcharge": [],
                    "rates_lower_than_usual": false,
                    "rates_higher_than_usual": true
                },
                {
                    "type": "flat_rate",
                    "minimum_distance": 5,
                    "minimum_time": 1,
                    "base_fare": "150.0",
                    "minimum_fare": "180.0",
                    "cost_per_distance": "45.0",
                    "waiting_cost_per_minute": 0,
                    "ride_cost_per_minute": "9.0",
                    "surcharge": [],
                    "rates_lower_than_usual": false,
                    "rates_higher_than_usual": true
                },
                {
                    "type": "flat_rate",
                    "minimum_distance": 5,
                    "minimum_time": 6,
                    "base_fare": "150.0",
                    "minimum_fare": "180.0",
                    "cost_per_distance": "30.0",
                    "waiting_cost_per_minute": 0,
                    "ride_cost_per_minute": "1.5",
                    "surcharge": [],
                    "rates_lower_than_usual": false,
                    "rates_higher_than_usual": true
                },
                {
                    "type": "flat_rate",
                    "minimum_distance": 5,
                    "minimum_time": 6,
                    "base_fare": "150.0",
                    "minimum_fare": "180.0",
                    "cost_per_distance": "22.5",
                    "waiting_cost_per_minute": 0,
                    "ride_cost_per_minute": "1.5",
                    "surcharge": [],
                    "rates_lower_than_usual": false,
                    "rates_higher_than_usual": true
                },
                {
                    "type": "airport drop",
                    "minimum_distance": 0,
                    "minimum_time": 0,
                    "base_fare": "75.0",
                    "minimum_fare": "90.0",
                    "cost_per_distance": "16.5",
                    "waiting_cost_per_minute": 0,
                    "ride_cost_per_minute": "1.5",
                    "surcharge": [],
                    "rates_lower_than_usual": false,
                    "rates_higher_than_usual": true
                },
                {
                    "type": "airport pickup",
                    "minimum_distance": 0,
                    "minimum_time": 0,
                    "base_fare": "75.0",
                    "minimum_fare": "90.0",
                    "cost_per_distance": "12.0",
                    "waiting_cost_per_minute": 0,
                    "ride_cost_per_minute": "1.5",
                    "surcharge": [],
                    "rates_lower_than_usual": false,
                    "rates_higher_than_usual": true
                },
                {
                    "type": "flat_rate",
                    "minimum_distance": 0,
                    "minimum_time": 0,
                    "base_fare": "75.0",
                    "minimum_fare": "90.0",
                    "cost_per_distance": "12.0",
                    "waiting_cost_per_minute": 0,
                    "ride_cost_per_minute": "1.5",
                    "surcharge": [],
                    "rates_lower_than_usual": false,
                    "rates_higher_than_usual": true
                }
            ]
        }
    ],
    "ride_estimate": {}
}

Upvotes: 0

Sangeet Jaiswal
Sangeet Jaiswal

Reputation: 106

You need to use the following url while testing(sandbox):

http://sandbox-t.olacabs.com/v1/products

Upvotes: 5

Related Questions