Follow

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use
Contact

Bol Retailer API: Exporting Offer File using Python and API Version 9

I am not able to export an Offers File when I try to fetch it via Python Code. I am trying to use the Bol. com API V9 and request a list of all offers.

headers = {
    'Accept': 'application/vnd.retailer.V9+json',
    "Content-Type": 'application/vnd.retailer.V9+json',
    "Authorization": "Bearer " + f"{access_token}"
}
params = {
    "format": "CSV",
}

url = "https://api.bol.com/retailer/offers/export"
response = requests.post(url, headers=headers, params=params)

Do you have an idea what I am missing out? Or is their API just buggy at this point?
The POST Call gives me a result which looks like that:

Status-Code: 400
{
"type" : "https://api.bol.com/problems",
"title" : "Bad Request",
"status" : 400,
"detail" : "The supplied accept header media type is not supported.",
"host" : "Instance-106",
"instance" : "https://api.bol.com/retailer/offers/export?format=CSV"
}

MEDevel.com: Open-source for Healthcare and Education

Collecting and validating open-source software for healthcare, education, enterprise, development, medical imaging, medical records, and digital pathology.

Visit Medevel

IMO the "Accept" Header looks absolutely fine according to their documentation.

>Solution :

Based on their documentation (found here) the server accepts data in Json format. So the correct code should look like:

headers = {
    'Accept': 'application/vnd.retailer.V9+json',
    "Content-Type": 'application/vnd.retailer.V9+json',
    "Authorization": "Bearer " + f"{access_token}"
}
params = {
    "format": "CSV",
}

url = "https://api.bol.com/retailer/offers/export"
response = requests.post(url, headers=headers, json=params)  # <-- note the json= parameter
Add a comment

Leave a Reply

Keep Up to Date with the Most Important News

By pressing the Subscribe button, you confirm that you have read and are agreeing to our Privacy Policy and Terms of Use

Discover more from Dev solutions

Subscribe now to keep reading and get access to the full archive.

Continue reading