Set user to admin

20 views
Skip to first unread message

Tony G

unread,
Jan 18, 2017, 10:05:15 AM1/18/17
to BaasBox
I am trying to use the REST API to change the role of a user from "registered" to "administrator".

I am using PHP to make a PUT request through curl with the following data:
{"role":{"name":"administrator","isrole":true},"visibleByTheUser":[],"visibleByFriends":[],"visibleByRegisteredUsers":{"company":"Company name","name":"Users Name","_social":[]},"visibleByAnonymousUsers":[]}

I am sending the request to myserveraddress:9000/admin/user/username with the session and app code in the HTTP headers.

I am getting an error response "The 'visibleByAnonymousUsers' field is missing" 

Can anyone help me spot what is wrong with this? Although this call is not in the API documentation I had read on some forums that this should work.

giastfader

unread,
Jan 18, 2017, 10:32:44 AM1/18/17
to BaasBox
Hi,
the visibleBy* fileds are objects not arrays.
and the "role" field is just a string.

Try to send:
{"role":"administrator","visibleByTheUser":{},"visibleByFriends":{},"visibleByRegisteredUsers":{"company":"Company name","name":"Users Name","_social":{}},"visibleByAnonymousUsers":{}}

Tony G

unread,
Jan 18, 2017, 12:25:25 PM1/18/17
to BaasBox
Thanks, that was exactly the problem. As those fields aren't being used I declared them as a null object instead of an empty array and it works fine now :)
Reply all
Reply to author
Forward
0 new messages