Creating a user via web service
Contents
There are two data points associated to an account when created via the EthosCE user interface, a user entity and a profile entity. Services creating accounts via web service must create both data points.
Creating a user with a profile
Creating a user via the web service can be accomplished with 2 requests to the system, with an extra request to verify the user does not already exist.
Verify the user does not exist
Send the user creation request
Send a profile creation request, assigning it to the user via uid.
Verify the user exists
There are two ways to verify an account exists, checking by e-mail or SSO ID.
GET user.json?mail=newuser@dlc-solutions.com
GET authmap.json?authname=EXTERNAL_SSO ID
Create user account
POST user.json
This payload will create a user with the roles “course author” (105847459) and “reviewer” (175031666), by sending the corresponding role ids (rid) as an array of values.
{
"name": "newuser_username",
"mail": "newuser@dlc-solutions.com",
"status": 1,
"roles": [
{
"id": 105847459
},
{
"id": 175031666
}]
}
A successful user creation request returns the following:
{"uri":"http://your-domain.com/user/123","id":"123","resource":"user"}
Create profile demographics
POST profile2.json
Associating a profile to an account requires the user id (uid) to be assigned to the user field in the profile data. In the creation request above the uid value returned is 123.
{
"user": 123,
"label": "Profile",
"type": "profile",
"field_first_name": "John",
"field_middle_name": "Middle",
"field_last_name": "Smith",
"field_profile_location":
{
"street": "123 S Broad Street",
"additional": "Suite 2260",
"city": "Philadelphia",
"province": "PA",
"postal_code": "19109",
"country": "us"
}
}
A successful profile creation request returns the following:
For an explanation of the information returned from the verification request, see Web Service Responses.
Updating a user role
User roles may be queried and updated via web services at the user endpoint. Only the changed fields need be included in a PUT request.
PUT user/123
Sending or updating roles is a destructive process. Any PUT updates sent to the user.json endpoint must contain all role ids, both existing and new. The payload below, if sent to the user created on this page, will remove “course author” (105847459), add “report viewer” (92961712), and keep the “reviewer” role (175031666),
Related Pages
Creating an SSO User via Webservice