Booked REST API issue with empty return body

Community Support for Booked Scheduler
Post Reply
pvdemael
Posts: 2
Joined: Fri May 28, 2021 12:31 pm

Booked REST API issue with empty return body

Post by pvdemael »

Hi,

I test the RESTful API using Postman (and in Matlab).
I managed to authenticate and get a list of all users via route /Web/Services/Users
But in a lot of cases calling Web/Services/Users/<userId> returns an empty body.
To check this I have written a little script in Matlab (with maual testing in Postman to check).

See the pseudocode and output below (usernames are obfuscated).
I see this mainly at the beginning and at the end of the sorted list of user ids.
What could be the issue?
I authenticate against a Drupal database with a custom plugin but the users are then stored in the local database.

Code: Select all

users = output of call to /Web/Services/Users
for u in users
   id = users(u).id
   user = output of call to /Web/Services/Users/id
   if user is not empty
      print(id, username, 'user found')
   else
      print(id, username, 'could not retrieve user'

Code: Select all

1 	<obfuscated>	could not retrieve user
2 	<obfuscated>	could not retrieve user
6 	<obfuscated>	could not retrieve user
7 	<obfuscated>	could not retrieve user
9 	<obfuscated>	could not retrieve user
...
21 	<obfuscated>	could not retrieve user
22 	<obfuscated>	could not retrieve user
23 	<obfuscated>	could not retrieve user
24 	<obfuscated>	user found
25 	<obfuscated>	user found
26 	<obfuscated>	user found
27 	<obfuscated>	user found
28 	<obfuscated>	user found
30 	<obfuscated>	could not retrieve user
31 	<obfuscated>	user found
33 	<obfuscated>	user found
34 	<obfuscated>	user found
35 	<obfuscated>	user found
36 	<obfuscated>	could not retrieve user
37 	<obfuscated>	user found
38 	<obfuscated>	user found
39 	<obfuscated>	user found
...
45 	<obfuscated>	user found
46 	<obfuscated>	user found
47 	<obfuscated>	user found
...
82	<obfuscated>	user found
83 	<obfuscated>	could not retrieve user
84 	<obfuscated>	could not retrieve user
85 	<obfuscated>	could not retrieve user
86 	<obfuscated>	could not retrieve user
...

pvdemael
Posts: 2
Joined: Fri May 28, 2021 12:31 pm

Re: Booked REST API issue with empty return body

Post by pvdemael »

I have found the source of the problem.
As soon as a user is appointed to one or more groups, meaning there is an entry in table user_groups, the service /Web/Services/Users/id returns an empty body.
This behavior is expected if a user making the request does not have group membership of the groups querying but is not desirable when the admin is making the call.
Is this a bug or a feature? If so why?

Post Reply