[#246] API: 400 Bad request error

Migrated from Redmine #246 | Author: Daniel Horowitz
Status: New | Priority: Normal | Created: 2018-09-24


Hello,
We’ve been using Node JS API client for simplybook api and it’s been working great over the last 12months.

Now we’re getting 400 Bad request error.
Here I paste my raw HTTP request ( I only changed URL from http to https).

Options:
{ method: ‘POST’,
host: ‘https://user-api.simplybook.me’,
path: ‘/login’,
headers:
{ host: ‘https://user-api.simplybook.me’,
‘content-type’: ‘application/json’,
‘content-length’: 134 } }

Body:
{“jsonrpc”:“2.0”,“method”:“getToken”,“params”:[“smylendev”,“API_KEY”],“id”:0}

Can you please help us figuring out this issue?

Daniel Horowitz wrote:

It returns this error.

Client: TODO Status Code: 400

Redmine Admin wrote:

It is working fine for me with your account. Please provide raw http request

Daniel Horowitz wrote:

I already provided raw HTTP request above.
How do you test? On API documentation | SimplyBook.me Online Scheduling?

I use node.js wrapper I developed.

Redmine Admin wrote:

if it is raw http request then you need to replace API_KEY with real API KEY from plugin settings :slight_smile:

Daniel Horowitz wrote:

yes, I use real API KEY in code, I just replaced with literal ‘API_KEY’ to send you.

Redmine Admin wrote:

please do the following command and send us result

curl https://user-api.simplybook.me/login -X POST -H 'content-type: application/json' -d '{"jsonrpc":"2.0","method":"getToken","params":["smylendev","API_KEY"],"id":0}'

Daniel Horowitz wrote:

Here’s the response from CURL.

curl: (92) HTTP/2 stream 1 was not closed cleanly: REFUSED_STREAM (err 7)

Redmine Admin wrote:

this not looks like response from curl in console. Please run it directly in terminal

Daniel Horowitz wrote:

I ran this directly on mac OS terminal.

Redmine Admin wrote:

Please do the following

curl https://user-api.simplybook.me/login --http1.1 -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"getToken","params":["smylendev","api key"],"id":0}'

Redmine Admin wrote:

Please do the following

curl https://user-api.simplybook.me/login --http1.1 -i -X POST -H 'Content-Type: application/json' -d '{"jsonrpc":"2.0","method":"getToken","params":["smylendev","api key"],"id":0}'

Daniel Horowitz wrote:

My api key is 244bb7e7c5b317c1aedc0a77731e12b7cdd5dc9e9b9adcb8ea1c05b2cda8f7e8

You can test it yourself.

Daniel Horowitz wrote:

Great, now it works.

How can we map additional params to node module?

–http1.1
-i

Redmine Admin wrote:

it is not additional param but protocol version. Please check node manual to choose right version