[#497] API Company does not exist - Urgent

Migrated from Redmine #497 | Author: Renaldas Cypas
Status: Closed | Priority: Immediate, there is BUG! | Created: 2020-03-18


could you check if I’m calling API correctly, getting:
{“error”:{“code”:-32000,“message”:“Company does not exist”,“data”:},“id”:“1”}

parameters:
company: servicestore
api key: b43aacfe9c47ae2aed851aee88421f6dee9b5d7c43fda1f6f33c891c14833545

Talked with support already, and they said:
irina 2:50 PM
@Renaldas I checked it with our techies and seems that use use the wrong company server and that is why you get an error. Please register all API requests you have here https://support.dev.simplybook.me/ and our developers will reply you asap

Redmine Admin wrote:

Hi, enterprise users need to use following API endpoint https://user-api.enterpriseappointments.com

Renaldas Cypas wrote:

ok it’s working now, thanks

Renaldas Cypas wrote:

Go another issue:

I tried to add new client,

used 2 API’s to get token:

  1. getToken()
  2. addClient ($clientData, $sendEmail) - passed values: {“name":“FrancesT.Perez”,“phone”:“+1502-810-4521”,“email”:"re@devhustler.com”}
  3. result: {“error”:{“code”:-32062,“message”:“Client email value is wrong”,“data”:},“id”:“1”}

Then tried another way, got user token (getUserToken) by passing my details to API: renaldas@origingrowth.co.uk

  1. Request: {“name":“FrancesT.Perez”,“phone”:“+1502-810-4521”,“email”:"re@devhustler.com”}
  2. Response: {“error”:{“code”:-32600,“message”:“Access denied”,“data”:},“id”:“1”}

Why I can’t add new user?

Dmytro Bondarev wrote:

Please provide RAW HTTP request.

Renaldas Cypas wrote:

Dmitry Bondarev wrote:

Please provide RAW HTTP request.

First request or second?

Dmytro Bondarev wrote:

The request for addClient method.

Renaldas Cypas wrote:

Dmitry Bondarev wrote:

The request for addClient method.

Can you give me example how it suppose to look, I’m calling it from C# HttpWebRequest and unable to give as it will be in bytes.

so I pass with a token “edee1820a261109f9e30285c100a55a593189c97d0dc04aad2ea330d26d8c33b”:
addClient({“name":“FrancesT.Perez”,“phone”:“+1502-810-4521”,“email”:"re@devhustler.com”}, false)

Renaldas Cypas wrote:

Headers:
{X-Company-Login: servicestore
X-Token: edee1820a261109f9e30285c100a55a593189c97d0dc04aad2ea330d26d8c33b
Content-Type: application/json-rpc
Host: user-api.enterpriseappointments.com
Content-Length: 139
Expect: 100-continue

}

Redmine Admin wrote:

This method is only available for User/Admin (you are using client API) API
Please check docs here API documentation | SimplyBook.me Online Scheduling

Renaldas Cypas wrote:

Redmine Admin wrote:

This method is only available for User/Admin (you are using client API) API
Please check docs here API documentation | SimplyBook.me Online Scheduling

but like I said above in the first post, I tried with admin user also, my user is admin

Redmine Admin wrote:

ok, then we still need to see raw HTTP request with method call and params
here is example of what we need to see

POST  HTTP/1.1
Host: user-api.simplybook.me
Content-Type: application/json; charset=UTF-8
Content-Length: 69
X-Company-Login: test
X-Token: f520b5d6096dd86a92da914e1f74425f3322564d9136a1bca61811962ecba5c1
Accept: application/json

{"jsonrpc":"2.0","method":"getFirstWorkingDay","params":["1"],"id":3}

Dmytro Bondarev wrote:

Please try following request:

POST https://user-api.enterpriseappointments.com/admin/
Content-Type: application/json
X-Company-Login: servicestore
X-User-Token: tokenhere

{
  "jsonrpc":"2.0",
  "method":"addClient",
  "params":[{"name":"FrancesT.Perez","phone":"+1502-810-4521","email":"re@devhustler.com"}, false]
}

Renaldas Cypas wrote:

Redmine Admin wrote:

ok, then we still need to see raw HTTP request with method call and params
here is example of what we need to see

[…]

It just not clear how I can pass parameters for addUser, am I doing it correcly? : {“name":“FrancesT.Perez”,“phone”:“+1502-810-4521”,“email”:"re@devhustler.com”}

Dmytro Bondarev wrote:

There is no addUser method.
If you need to pass parameters to addClient please see example above it works properly. (The @params@ is array and first param is object with client data)

Renaldas Cypas wrote:

Dmitry Bondarev wrote:

There is no addUser method.
If you need to pass parameters to addClient please see example above it works properly. (The @params@ is array and first param is object with client data)

So I did:

POST /admin/ HTTP/1.1
Host: user-api.enterpriseappointments.com
X-Token: 7d69212957e1b5834ae142159ce57ef5f51dcebfcb98a884902dbba464d33078
X-Company-Login: servicestore
Content-Type: application/json

{
“jsonrpc”:“2.0”,
“method”:“addClient”,
“params”:[{“name":“FrancesT.Perez”,“phone”:“+1502-810-4521”,“email”:"re@devhustler.com”}, false]
}

and response:

{
“error”: {
“code”: -32600,
“message”: “Access denied”,
“data”:
},
“id”: null,
“jsonrpc”: “2.0”
}

Redmine Admin wrote:

Please use admin API where ypu have to pass X-User-Token

Renaldas Cypas wrote:

Redmine Admin wrote:

Please use admin API where ypu have to pass X-User-Token

Thanks it worked, I need bit help with what I need to achieve, so when user is registered trough our site using API, I want them to be able to login, how normally we should store login data when later we want to pass it to booking service and etc.

I saw this call: getClientByLoginHash ($hash) but no idea how to get login hash?

Another issue I see, user can register multiple times, how to prevent it, I tried to find API call where I can check if user exist based on email, but couldn’t find.

Dmytro Bondarev wrote:

Hi!

  1. You should use “Client login” custom feature. it will prevent to register client multiple times.
  2. Please use @addClient@ in Public service. (It will return client info with @client_hash@)
  3. To get client use @getClientInfo@ and pass client @id@ and @sign@, where @sign = md5(clientId + clientHash + secretKey);@

If you prefer to use Admin service, then you can just add client as soon as your client sign up with you and then call @book@ method of Admin service and just pass client id.

Renaldas Cypas wrote:

Hi,

which API call should I use to get all available time slots for service by using ANY service provider? I want to see example like this:

I enabled functionality to use ANY provider, tried this API call:
{“jsonrpc”:“2.0”,“method”:“getServiceAvailableTimeIntervals”,“params”:[“2020-03-23”,“2020-03-31”,“9”,“2”,100],“id”:1}

but seems it’s not what I need