This is the fourth in a series of practice exercises to help you
become familiar with Cherwell's REST API Discovery Tool. We highly recommend
that you complete the following exercises before you begin:
In this exercise, you will use a Model Schema to build a complex
request parameter, which will be passed into the API call in order to create a
new User.
- Log into the REST API Discovery Tool. See
Opening the REST API Discovery Tool.
- Click the
Users heading to expand the list of
operations.
- Click
/api/V2/saveuser to expand the operation's
details.
- Set the contents of the request Value field to match the model
schema.
In the next steps you will edit
the JSON code as you did for
Practice Exercise: Get Quick Search Configuration for Business
Objects.
You can edit the code directly in Swagger, or you can copy the code into a text
editor so that it is easier to work with.
- Set the value for accountLocked to
false.
- Get the Business Object ID for UserInfo.
- Set the value for busObId to the Business Object ID for UserInfo
- Delete the key-value pairs for busObPublicId and busObRecId from
the JSON code. These values are not required for the creation of a new User.
- Set the value for displayName to
Test User.
- Set the value for ldapRequired to
false.
- Set the value for loginId to
Test.
- Set the value for nextPasswordResetDate to
null.
- Set the value for password to
P@ssword. Ensure this value meets the password
complexity requirements set in
CSM.
- Ensure the value for passwordNeverExpires is set to
true.
- Set the value for securityGroupId to the Security Group ID for the
User's Security Group. For this exercise, choose any Security Group.
Call
api/V2/getsecuritygroups to see a list of
Security Groups and their IDs.
- Ensure the value for userCannotChangePassword is set to
true.
- Set the values for userInfoFields. Call
/api/V1/getbusinessobjectschema/busobid/{busobid}
to get the schema for the UserInfo Business Object. For each field:
- Ensure the value for dirty is set to
true.
This setting must be enabled for each field in order to save
the field values.
- Set the value for displayName to the Display Name.
- Set the value for fieldId to the Field ID.
- Set the value for name to the Name.
- Set the value for the field.
- Set the value for userMustChangePasswordAtNextLogin to
false.
- Delete the key-value pair for windowsUserId. You are creating a
Cherwell User, so this value is unnecessary. See the example below of the full
request body:
{
"accountLocked": false,
"busObId": "9338216b3c549b75607cf54667a4e67d1f644d9fed",
"displayName": "Test User",
"ldapRequired": false,
"loginId": "Test",
"nextPasswordResetDate": "null",
"password": "P@ssword",
"passwordNeverExpires": true,
"securityGroupId": "93d5aa70c8893014a2b7dc4733953c6185777e92bf",
"userCannotChangePassword": true,
"userInfoFields": [
{
"dirty": true,
"displayName": "Full Name",
"fieldId": "BO:9338216b3c549b75607cf54667a4e67d1f644d9fed,FI:93382178280a07634f62d74fc4bc587e3b3f479776",
"name": "FullName",
"value": "Test User"
},
{
"dirty": true,
"displayName": "Email",
"fieldId": "BO:9338216b3c549b75607cf54667a4e67d1f644d9fed,FI:933821793f43a638cf23e34723b907956d324ad303",
"name": "Email",
"value": "[email protected]"
}
],
"userMustChangePasswordAtNextLogin": false,
}
- Click
Try it out!
Pay attention to the HTTP response codes you receive, and
troubleshoot as appropriate:
200
| Indicates a successful call.
|
400
| Indicates a bad request due to missing
parameters or incorrect formatting.
|
402
| Indicates a failed call. The request
body is formatted correctly, but the system is unable to execute the request.
|
404
| Indicates a failed call due to a
nonexistent URL.
|
- Optional:
Try adding or updating field values for the User you just
created.