My json file isnt correct for the api call and get a 400 error

I am trying to use the Bol API documentation to send my products directly to the platform. I created a scenario where an Excel file is filled out and then sent to my WordPress site (which works) and simultaneously to the Bol API (https://api.bol.com/retailer/offers).

I tried 2 different json formats:

{
  "ean": "{{9.`12`}}",
  "condition": "{{9.`49`}}",
  "conditionComment": "Geen beschadigingen, gloednieuw",
  "referenceCode": "{{9.`21`}}",
  "onHoldByRetailer": false,
  "unknownProductTitle": "{{9.`0`}}",
  "description": "{{9.`23`}}",
  "pricing": {
    "bundlePrices": [
      {
        "quantity": 1,
        "price": {{9.`8`}}
      }
    ]
  },
  "stock": {
    "amount": {{9.`5`}},
    "managedByRetailer": true
  },
  "fulfilment": {
    "method": "{{9.`10`}}",
    "deliveryCode": "24uurs"
  }
}

and

{
  "language": "nl",
  "attributes": [
    {
      "id": "EAN",
      "values": [
        {
          "value": "{{9.`12`}}"
        }
      ]
    },
    {
      "id": "condition",
      "values": [
        {
          "value": "{{9.`49`}}"
        }
      ]
    },
    {
      "id": "referenceCode",
      "values": [
        {
          "value": "{{9.`21`}}"
        }
      ]
    },
    {
      "id": "onHoldByRetailer",
      "values": [
        {
          "value": false
        }
      ]
    },
    {
      "id": "unknownProductTitle",
      "values": [
        {
          "value": "{{9.`0`}}"
        }
      ]
    },
    {
      "id": "description",
      "values": [
        {
          "value": "{{9.`23`}}"
        }
      ]
    },
    {
      "id": "pricing",
      "values": [
        {
          "quantity": 1,
          "price": {{9.`8`}}
        }
      ]
    },
    {
      "id": "stock",
      "values": [
        {
          "amount": {{9.`5`}},
          "managedByRetailer": true
        }
      ]
    },
    {
      "id": "fulfilment",
      "values": [
        {
          "method": "{{9.`10`}}",
          "deliveryCode": "24uurs"
        }
      ]
    }
  ]
}

But still get a 400 error. Any one who can help me out?

Hi @Joost.7AM,

What is the exact error that you receive? Is there a message besides the 400 status?

Cheers,
Henk

Hi @Henk-Operative,

There isn’t a direct error. But this is what i got:

Schermafbeelding 2024-07-04 153048

This is the bundle content input:

[
    {
        "ca": null,
        "qs": [],
        "url": "https://api.bol.com/retailer/offers",
        "data": "{\n  \"language\": \"nl\",\n  \"attributes\": [\n    {\n      \"id\": \"EAN\",\n      \"values\": [\n        {\n          \"value\": \"9507622784796\"\n        }\n      ]\n    },\n    {\n      \"id\": \"condition\",\n      \"values\": [\n        {\n          \"value\": \"NEW\"\n        }\n      ]\n    },\n    {\n      \"id\": \"referenceCode\",\n      \"values\": [\n        {\n          \"value\": \"TZ-RU-BE-100-R\"\n        }\n      ]\n    },\n    {\n      \"id\": \"onHoldByRetailer\",\n      \"values\": [\n        {\n          \"value\": false\n        }\n      ]\n    },\n    {\n      \"id\": \"unknownProductTitle\",\n      \"values\": [\n        {\n          \"value\": \"Raved Tafelzeil Ruit\"\n        }\n      ]\n    },\n    {\n      \"id\": \"description\",\n      \"values\": [\n        {\n          \"value\": \"Dit is een tafelkleed\"\n        }\n      ]\n    },\n    {\n      \"id\": \"pricing\",\n      \"values\": [\n        {\n          \"quantity\": 1,\n          \"price\": 20.59\n        }\n      ]\n    },\n    {\n      \"id\": \"stock\",\n      \"values\": [\n        {\n          \"amount\": 5,\n          \"managedByRetailer\": true\n        }\n      ]\n    },\n    {\n      \"id\": \"fulfilment\",\n      \"values\": [\n        {\n          \"method\": \"FBR\",\n          \"deliveryCode\": \"24uurs\"\n        }\n      ]\n    }\n  ]\n}",
        "gzip": true,
        "method": "post",
        "headers": [
            {
                "name": "Authorization",
                "value": "Bearer [api code]"
            },
            {
                "name": "Content-Type",
                "value": "application/json"
            }
        ],
        "timeout": null,
        "useMtls": false,
        "authPass": null,
        "authUser": null,
        "bodyType": "raw",
        "contentType": "application/json",
        "serializeUrl": false,
        "shareCookies": false,
        "parseResponse": false,
        "followRedirect": true,
        "useQuerystring": false,
        "followAllRedirects": false,
        "rejectUnauthorized": true
    }
]

And this budle content output:

[
    {
        "ca": null,
        "qs": [],
        "url": "https://api.bol.com/retailer/offers",
        "data": "{\n  \"language\": \"nl\",\n  \"attributes\": [\n    {\n      \"id\": \"EAN\",\n      \"values\": [\n        {\n          \"value\": \"9507622784796\"\n        }\n      ]\n    },\n    {\n      \"id\": \"condition\",\n      \"values\": [\n        {\n          \"value\": \"NEW\"\n        }\n      ]\n    },\n    {\n      \"id\": \"referenceCode\",\n      \"values\": [\n        {\n          \"value\": \"TZ-RU-BE-100-R\"\n        }\n      ]\n    },\n    {\n      \"id\": \"onHoldByRetailer\",\n      \"values\": [\n        {\n          \"value\": false\n        }\n      ]\n    },\n    {\n      \"id\": \"unknownProductTitle\",\n      \"values\": [\n        {\n          \"value\": \"Raved Tafelzeil Ruit\"\n        }\n      ]\n    },\n    {\n      \"id\": \"description\",\n      \"values\": [\n        {\n          \"value\": \"Dit is een tafelkleed\"\n        }\n      ]\n    },\n    {\n      \"id\": \"pricing\",\n      \"values\": [\n        {\n          \"quantity\": 1,\n          \"price\": 20.59\n        }\n      ]\n    },\n    {\n      \"id\": \"stock\",\n      \"values\": [\n        {\n          \"amount\": 5,\n          \"managedByRetailer\": true\n        }\n      ]\n    },\n    {\n      \"id\": \"fulfilment\",\n      \"values\": [\n        {\n          \"method\": \"FBR\",\n          \"deliveryCode\": \"24uurs\"\n        }\n      ]\n    }\n  ]\n}",
        "gzip": true,
        "method": "post",
        "headers": [
            {
                "name": "Authorization",
                "value": "Bearer [api code]"
            },
            {
                "name": "Content-Type",
                "value": "application/json"
            }
        ],
        "timeout": null,
        "useMtls": false,
        "authPass": null,
        "authUser": null,
        "bodyType": "raw",
        "contentType": "application/json",
        "serializeUrl": false,
        "shareCookies": false,
        "parseResponse": false,
        "followRedirect": true,
        "useQuerystring": false,
        "followAllRedirects": false,
        "rejectUnauthorized": true
    }
]

So that’s why i’ve no idea what’s happening.

Hi @Joost.7AM,

Try to adjust your header values to the headers that are documented here: bol.com retailer API v10.0 public

Accept = application/vnd.retailer.v10+json

Content-Type = application/vnd.retailer.v10+json

This is for the v10 of the Retailer API, there are some descrepancies between the sample JSON in the documentation and the first JSON that you sent, so check if the JSON you are passing should be accepted by the endpoint. (the parameters seem to be better documented here: ReDoc)

Cheers,
Henk

Hi @Henk-Operative, thanks for the support.

I adjust the headers, but without succes. still a 400 error.

{
  "ean": "{{9.`12`}}",
  "condition": {
    "name": "{{9.`49`}}",
    "category": "{{9.`49`}}"
  },
  "reference": "{{9.`21`}}",
  "onHoldByRetailer": false,
  "unknownProductTitle": "{{9.`0`}}",
  "pricing": {
    "bundlePrices": [
      {
        "quantity": 1,
        "unitPrice": {{9.`8`}}
      }
    ]
  },
  "stock": {
    "amount": {{9.`5`}},
    "managedByRetailer": true
  },
  "fulfilment": {
    "method": "{{9.`10`}}",
    "deliveryCode": "VVB"
  }
}

Thank you, @Joost.7AM

I am not sure what the cause of the 400 error is, whether it is with the body or with the headers or the connection in general.

Another way to troubleshoot the reqeust is via the Integromat DevTool, where you can see exactly what is sent to the external API and what the response (including any messages) is.

If that doesn’t work, I am available for consultation. You can contact me at henk@operative.pro

Cheers,
Henk

Thanks @Henk-Operative, didn’t know about the DevTool.

This is the response:

{
    "title": "Problem with JWT",
    "status": 400,
    "detail": "Supplied JWT is malformed or unsupported"
}

So the JSON Web Token isn’t correct.

Here’s the file, i don’t get where the problem is…

{
  "ean": "{{9.`12`}}",
  "condition": {
    "name": "{{9.`49`}}",
    "category": "{{9.`49`}}"
  },
  "reference": "{{9.`21`}}",
  "onHoldByRetailer": false,
  "unknownProductTitle": "{{9.`0`}}",
  "pricing": {
    "bundlePrices": [
      {
        "quantity": 1,
        "unitPrice": {{9.`8`}}
      }
    ]
  },
  "stock": {
    "amount": {{9.`5`}},
    "managedByRetailer": true
  },
  "fulfilment": {
    "method": "{{9.`10`}}",
    "deliveryCode": "24uurs-21"
  }
}{
  "ean": "{{9.`12`}}",
  "condition": {
    "name": "{{9.`49`}}",
    "category": "{{9.`49`}}"
  },
  "reference": "{{9.`21`}}",
  "onHoldByRetailer": false,
  "unknownProductTitle": "{{9.`0`}}",
  "pricing": {
    "bundlePrices": [
      {
        "quantity": 1,
        "unitPrice": {{9.`8`}}
      }
    ]
  },
  "stock": {
    "amount": {{9.`5`}},
    "managedByRetailer": true
  },
  "fulfilment": {
    "method": "{{9.`10`}}",
    "deliveryCode": "24uurs-21"
  }
}

Hi @Henk-Operative, it took blood, sweat and tears, but we managed to get a new product on Bol.

Thanks for your help and time.

2 Likes

Hi @Joost.7AM,

Thank you for your response, I am happy to hear that it worked!

How did you manage to resolve the issue?

Cheers,
Henk

2 Likes

Hi @Henk-Operative, i find out that you need the jwt token instead of the client credentials. So first you need to create an extra http module to activate the JWT token.

3 Likes