[#1264] Can't create a batch

Migrated from Redmine #1264 | Author: Alan Miranda
Status: Feedback | Priority: High, I’m very impatient | Created: 2024-08-20


I’m implementing SimplyBook in my API. The website allows reservations for more than one person. While the reservation might be attached to a single client, it can cover multiple people.
I found in another answer that I need to create a batch to add a number of people, but it must be done using the JSON-RPC 2.0 protocol.

Currently, I’m testing these requests in Postman. I successfully obtained the token using the following request:
curl --location ‘https://user-api.simplybook.me/login
–header ‘Content-Type: application/json’
–data ‘{
“jsonrpc”: “2.0”,
“id”: “1”,
“method”: “getToken”,
“params”: {
“companyLogin”: “{{myCompany}}”,
“apiKey”: “{{myApiToken}}”
}
}’

After that, I use the token to try creating a batch:
curl --location ‘https://user-api.simplybook.me/admin
–header ‘X-Company-Login: {{myCompany}}’
–header ‘X-Token: {{myApiToken}}’
–header ‘Content-Type: application/json’
–data ‘{
“jsonrpc”: “2.0”,
“id”: “1”,
“method”: “createBatch”
}’

However, I’m receiving the following error:
{
“error”: {
“code”: -32600,
“message”: “Access denied”,
“data”: []
},
“id”: “1”,
“jsonrpc”: “2.0”
}

Any guidance on how to resolve it would be greatly appreciated.

Thank you in advance for your help.

Dmytro Bondarev wrote:

Hi, it seems you are using invalid token.
In second call your should pass result from first call (login).

Alan Miranda wrote:

Dmytro Bondarev wrote:

Hi, it seems you are using invalid token.
In second call your should pass result from first call (login).

Sorry, I made a mistake when I wrote the question. Yes, I’m using the token I received from the first request.
curl --location ‘https://user-api.simplybook.me/admin
–header ‘X-Company-Login: {{myCompany}}’
–header ‘X-Token: {{firstRequestToken}}’
–header ‘Content-Type: application/json’
–data ‘{
“jsonrpc”: “2.0”,
“id”: “1”,
“method”: “createBatch”
}’

And as I mentioned previously, I’m getting an “Access Denied” error.

Dmytro Bondarev wrote:

Hi, as i see you are trying to use admin API.
to use admin API you have to login as user and use that token:

please check User/Admin API (Company administration service) authorization part