Description
The SaveUser API allows the Account Owner to create or update a User.
All users have the default system fields "groups", "name", "login", "email", "password" and "isSuspended". The fields "name", "email", and "password" are single valued. Any other parameters passed to SaveUser will be treated as application-defined attributes and will be treated as multi-valued fields. Please note that except for these specific user fields, SaveUser behaves exactly like the SaveDocument API.
User management APIs may only be called using the account owner credentials from within server scripts, or by a user to access his own profile.
Specific Request Parameters
(Refer to Common Request Parameters)
Name | Description | Required | Default | Possible Values |
---|---|---|---|---|
login | The username used to authenticate a user’s requests. | Yes |
|
|
password | The user’s password that will be used to sign the user’s requests | Yes on first creation. No on update. Set empty if sent empty. |
|
|
name | The full name of the user | Yes. Set empty if sent empty. |
|
|
The email of the user | No. Set empty if sent empty. |
|
| |
groups | The multiple field of groups to which the user will be added. | No. If sent empty or if one group is invalid, the error "Invalid Group" will be thrown. |
|
|
isSuspended | The field used to specify if a user is suspended or not. Note that a suspended user still exists in the system but is treated as if he was deleted. He can be reactivated by calling SaveUser with the field isSuspended=true. | No. | true | true or false |
apsdb.update | Sent in case the user wants to update existing user. Sent user should be valid. | No. If sent empty or false or not sent, user will be created. If sent equal to true and sent user exists and is valid, user is updated. |
|
|
[fieldName] | This parameter name in the request is the name of the custom user attribute to be stored, and its value is the value of the attribute. | No. If field already exists and is sent empty, field will be deleted, else the new value will override the existing value. Note that it cannot be sent as multiple as an exception will be thrown. |
|
|
[fieldName].apsdb.fieldType | The type of the data to be stored in the corresponding attribute field. The field is specified by the first portion of the parameter name. i.e. This parameter will set the content type of the field whose name is [fieldName]. | No | string | string, numeric, date, text, file, geospatial. |
[fieldName].apsdb.delete | Parameter used to delete a field or a specific value. | No |
|
|
apsdb.multivalueAppend | Specifies that the given field values will be appended to, instead of replacing, the current field values. Contains a comma separated list of field names to which the values specified will be appended. | No |
|
|
apsdb.runAs | Allows the owner to run a service as one of his own users. The possible values are any of the usernames. | No |
|
|
Specific Response Elements
(Refer to Common Response Elements)
Specific Logical Errors
(Refer to Common Logical Error Codes and SaveDocument API's "Specific Logical Errors" section)
Below is the list of additional errors you might get in the special case of saving a user document.
Error | Message | Status Code |
---|---|---|
PASSWORD_REQUIRED | The password was not sent in the request. | 400 |
INVALID_EMAIL | An invalid email address is sent in the request. | 400 |
DUPLICATE_USER | The user [login] already exists. | 400 |
INVALID_GROUP | Trying to add a user [login] to a group [groupName] that does not exist. | 400 |
PARAMETER_REQUIRED | The parameter [login] is required in SaveUser | 400 |
INVALID_USER | The user [login] does not exist. | 400 |
NAME_REQUIRED | The name was not sent in the request. | 400 |
INVALID_FIELD_VALUE | failed to update user [login] | 400 |
INVALID_FIELD_VALUE | failed to create user [login] | 400 |
INVALID_FIELD_VALUE | Field [fieldName] cannot contain values that are not strings | 400 |
INVALID_FIELD_VALUE | Field [fieldName] cannot contain values that are not numeric | 400 |
INVALID_FIELD_VALUE | Field [fieldName] cannot contain values that are not dates | 400 |
INVALID_FIELD_VALUE | Field [fieldName] cannot contain values that are not text | 400 |
INVALID_FIELD_VALUE | Field [fieldName] has an invalid value | 400 |
INVALID_USERNAME |
| 400 |
Examples
Sample Request
Request URL: http://sandbox.apstrata.com/apsdb/rest/[authenticationkey]/SaveUser?apsws.time=[timestamp]&apsws.authSig=[signature]
POST parameters:
login = [user_login] password = [user_password] name = [user_full_name] email = [user_email] apsdb.update = [true|false] groups = [user_group]
Sample XML Response
Success XML:
<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd"> <metadata> <requestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</requestId> <status>success</status> </metadata> </response>
Failure XML:
<response xmlns="http://www.apstrata.com/services/schemas/apstrata_database_response.xsd"> <metadata> <requestId>xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx</requestId> <status>failure</status> <errorCode>[errorCode]</errorCode> <errorDetail>[failMsg]</errorDetail> </metadata> </response>
Sample JSON Response
{"response": { "metadata": { "requestId": "xxxxxxxx-xxxx-xxxx-xxxx-xxxxxxxxxxxx", "status": "success" } }}