[#741] JSON parse error on receiving a response from getToken method in company public service

Migrated from Redmine #741 | Author: Katsunori Kanda
Status: Feedback | Priority: High, I’m very impatient | Created: 2021-07-26


I got an error on calling getToken API in company public service. Last week it worked but today I got the following error. It seems like receiving a html document.

/Users/hj3406/ws/xxxxxx/test.js:12
  if(err) throw err;
          ^

SyntaxError: Unexpected token < in JSON at position 0
    at JSON.parse ()
    at Object.Utils.JSON.parse (/Users/hj3406/ws/xxxxxx/node_modules/jayson/lib/utils.js:261:22)
    at IncomingMessage. (/Users/hj3406/ws/xxxxxx/node_modules/jayson/lib/client/http.js:84:22)
    at IncomingMessage.emit (events.js:387:35)
    at endReadableNT (internal/streams/readable.js:1317:12)
    at processTicksAndRejections (internal/process/task_queues.js:82:21)
const jayson = require('jayson');


const companyLogin = "";
const apiKey = "";
const client = new jayson.client.https({
  host: 'user-api.simplybook.me',
  path: '/login'
});

const ret = client.request('getToken', [companyLogin, apiKey], (err, res) => {
  if(err) throw err;

  console.log('getToken: result=' + res.result);
  return res.result;
});

testing environment

Katsunori Kanda wrote:

The response from API was the attached html.

Katsunori Kanda wrote:

Katsunori Kanda wrote:

The response from API was the attached html.

It’s failed to upload html, so I attached the html document received from API as a code.


    
    Please wait
    
    
    
    




Allow 3rd party cookies

Hey, we need your agreement to provide us access to cookies inside widget!

Allow Book in new tab

There is a queue to make a booking.

No worries, you are already waiting in line!

Dmytro Bondarev wrote:

Hi!
Please provide your company login and API endpoint.

Katsunori Kanda wrote:

Dmitry Bondarev wrote:

Hi!
Please provide your company login and API endpoint.

My company login is “tqdsample”. API endpoint is “user-api.simplybook.me/login”.

Dmytro Bondarev wrote:

Please use following API endpoint: user-api.simplybook.asia/login .
The same for other API calls - please use .asia domain.

Katsunori Kanda wrote:

Dmitry Bondarev wrote:

Please use following API endpoint: user-api.simplybook.asia/login .
The same for other API calls - please use .asia domain.

Thank you. It worked!