Baselinker API requests

How should I set up a Query param, and how should the cURL for baselinker API look like?

Here is a Baselinker API documentation
https://api.baselinker.com/index.php

Introduction

The API enables the information exchange between an external system and BaseLinker.
Communication uses data in JSON format. To make a request to the API, send the proper POST request to:
https://api.baselinker.com/connector.php

To send a request for each method, a token is required. The token is assigned directly to the BaseLinker user account. User can generate API token in BaseLinker panel in “Account & other → My account → API” section.
Authorization with http header (X-BLToken) is recommended.

3 values must be submitted to the connector.php file via POST:

  1. token - unique user API key - DEPRECATED, please use X-BLToken header
  2. method - the name of the requested API method
  3. parameters - arguments of the requested function in JSON format

Sample:curl 'https://api.baselinker.com/connector.php' -H 'X-BLToken: 1-23-ABC' --data-raw 'method=getOrders&parameters=%7B%22date_from%22%3A+1407341754%7D'

The cURL is not very clear for me:
what is “-H”?
What are ’ separators in the cURL?
Is --data-raw a part of the curl that will be created with request (or it is fine when I set it in Body section like I did)?

I’v set api key, so no longer “error_message”:“No user token provided.” appears.
As a body I selected raw/JSON

So how should I set params to make my getOrders request?
What should i put in Body section?

I tried a lot but nothing seems to be working - always the same message:
“error_message”:“An empty or unknown method has been used”

Please help - because i’m stuck :confused:

Hi @pablogemba

You can use the “Import” option in Postman and select the “Raw Text” option to import cURL straight in to Postman, like this;

image

This will automatically create the request in Postman like this;
image

image

Ok.

Just did what you told me and there are some problems:
1st. In API documentation, it’s stated - Communication uses data in JSON format.
And here it’s set for x-www-form-urlencoded.
2nd. X-BLToken is set as 1-23-ABC (I just went to Authorization tab and made it as API doc said


Hope that is correct…
But when I hit SEND, it’s the same outcome again.

{“status”:“ERROR”,“error_code”:“ERROR_UNKNOWN_METHOD”,“error_message”:“An empty or unknown method has been used”}

Any idea why ?
Is it because I should make parameters in JSON?

Can you provide screenshots of what you have tried?

I tried


Of course there is a X-BLToken on the 1st place
And I’m writing Parameters
image

@pablogemba

In the screenshot where you have the key\value that you want to add to the header.

You have the key as “X-BLToken” and the value as {{Token}} which is a variable that I don’t think you have set anywhere.

Therefore, the error “an empty or unknown method”.

Ideally, this should be set as an environment variable.

So - under the {{Token}} is a value of my real token which I got from my Baselinker.
It’s set like that, because I don’t want to share an API token in public.

@pablogemba

Ok, but where do you have this set?

Can you confirm that it is set in an environment variable?

Hi guys,
The problem can be resolved by:

  1. Import a cURL file like it has been shown
  2. In Body part - parameters, please make sure to input the correct unix time (without “+”)
  3. In authorization
  4. Headers I’ve got like this:

And after all of this it works fine. Hope it helps.

1 Like

Hello,
It’s another case with BaseLinker

Generally speaking, my goal is to add and update in live-mode stock positions from https://www.ordereco.com/stock-position/ to BaseLinker virtual warehouse ID: 67017 “E Group BV - local” + catalogue (inventory_ID = 36705)

I’ve used Kadoa to create GET data

Now, I am generating API call logs (screenshot attached) , but in Postman I’ve stuck on:

{
“status”: “ERROR”,
“error_code”: “ERROR_STORAGE_ID”,
“error_message”: “Invalid storage identifier provided.”
}

&

{
“status”: “ERROR”,
“error_code”: “ERROR_STORAGE_ID”,
“error_message”: “Invalid catalogue identifier provided.”
}

https://api.baselinker.com/index.php?method=addInventoryProduct

Thank you in advance for help!



we can also use this as example (from Baselinker support)

how to configure these parameters?

there are still errors when adding the warehouse ID, product number…

Please somebody


give me a hint :slight_smile:

{
“status”: “ERROR”,
“error_code”: “ERROR_STORAGE_ID”,
“error_message”: “Invalid catalogue identifier provided.”
}

@research-pilot-84736

It should be a single parameters field with an JSON string as the value that includes all of the required parameters for that method.

Use the API documentation for the particular method to see what the JSON structure needs to look like.

For example…

addInventoryProduct - baselinker.com

You might want to consider using one of the online JSON minifier tools to format your JSON string before adding it in Postman.

JSON Minify Online to Minify, Compact JSON Data and Best (jsonformatter.org)

Which will return something like this from the example…

{"inventory_id":"307","product_id":"2685","is_bundle":false,"ean":"983628103943","sku":"EPL-432","tax_rate":23,"weight":0.25,"height":0.3,"width":0.2,"length":0.05,"star":2,"manufacturer_id":5,"category_id":3,"prices":{"105":20.99,"106":23.99},"stock":{"bl_206":5,"bl_207":7},"locations":{"bl_206":"A-5-2","bl_207":"B-1-5"},"text_fields":{"name":"Harry Potter and the Chamber of Secrets","description":"Basic book description","description_extra1":"Additional description, e.g. of the entire product category","description_extra2":"Second additional description - e.g. IMG tags with photos from an external server","features":{"Cover":"Hardcover","Pages":"300","Language":"English"},"name|de":"Harry Potter und die Kammer des Schreckens"},"images":{"0":"url:http://placehold.it/250x250/image.jpg","3":"url:http://placehold.it/250x250/image2.jpg","5":"url:http://placehold.it/350x350/image34.jpg"},"links":{"shop_23":{"product_id":8,"variant_id":3}}}

OK, so add parameters one-by-one using comma separator?
Was thinking each parameter should have new row

So could you be so kind and advice, how to reach this goal?

No, it needs to be a JSON object as per the documentation.

The field is called “parameters”, not “parameter”.

Like the example I posted in my last post.

Thanks Mike!

Please take a look:

  1. I was able to manually add first position from https://www.ordereco.com/stock-position/
  2. I’ve used your example (thank you)
  3. How to automate process and sync all products from https://www.ordereco.com/stock-position/ with Baselinker? I’ve generated GET data @ Kadoa

Screenshots attached

Best,
Lukasz



Sorry, but I can just see this being one question after another.

I don’t mind helping but you need to have at least tried to do this yourself first as this is your task to complete, not mine.

Therefore I recommend that you visit the Learning Centre in the first instance.

Overview | Postman Learning Center

Including the Postman Training links under “Resources”.

image

I would recommend the “Galaxy APIs 101” course first as it gets you used to the application GUI features.

Then the “Galaxy Testing and Automation” course which teaches you how to assert the responses. It includes chaining requests which is what you are now asking.

I would also recommend looking up JSON and JSON arrays in particular, as you will need to learn how to target the elements in the Kadoa response.

1 Like

Thank you so much

I am not asking for “making the job done”, but some source and clue, how to achieve the goal I am looking for

as I have no coding experience

Best,
Lukasz

@research-pilot-84736

Hence the recommendation to go through the Learning Centre resources first.

1 Like