Oracle by Example brandingGet Started with User Accounts REST API - Manage User Roles

section 0Before You Begin

This 20-minute tutorial shows you how to manage user roles using the userAccounts REST API.

Before you begin, you should have access to a user whose account you can modify who has at lease one role that you can delete.


section 1Query a User Account by User Name

If you completed the Manage User Accounts tutorial, this exercise is completed. You may need to modify the Username in the parameter, but you can simply re-run the Query Account by User Name REST call.

  1. Add a request to ##_UserAccountsCollection.

  2. Give the request the name Query Account by User Name.
  3. Click Save to ##_UserAccountsCollection.
  4. Specify the method as GET.
  5. Enter the url:

    Note:Replace UserName in the URL with the user name of the user whose account you are accessing.

    {{url}}/hcmRestApi/resources/11.13.18.05/userAccounts?q=Username = 'john.b.doe@example.com'

  6. Give the request the following headers:

    Note: Headers can be saved in presets in postman for reuse.

    Key Value
    REST-Framework-Version 4
  7. Click Send.

    The response should be 200 OK.

  8. Click Save.

section 2View the Assigned Roles

  1. In the response for Query Account by User Name click the collection link for the userAccountRoles.

  2. Click Save As and give the request the name View the Assigned Roles.
  3. Click Save to ##_UserAccountsCollection.
  4. Click Send.

    The response should be 200 OK.

  5. Click Save.

section 4Revoke a Role

  1. In the response for View the Assigned Roles click the self link for the userAccountRoles item you will delete.

  2. Click Save As and give the request the name Revoke a Role Access.
  3. Click Save to ##_UserAccountsCollection.
  4. Specify the method as DELETE.
  5. Give the request the following headers:

    Note: Headers can be saved in presets in postman for reuse.

    Key Value
    REST-Framework-Version 4
    Content-Type application/vnd.oracle.adf.resourceitem+json
  6. Click Send.

    The response should be 204 No Content.

  7. Click Save.

section 5Assign a New Role to a User Account

Get Role Id

  1. Create a new request called Get Role Id.

  2. Click Save to ##_UserAccountsCollection.
  3. Specify the method as GET.
  4. Enter the url:

    Note:Replace RoleCode in the URL with the role code of the data role you created in the Get Started with User Accounts REST API - Authorization tutorial. If you would like to use a different role, ensure it is assignable via the role provisioning rules.

    {{url}}/hcmRestApi/resources/latest/rolesLOV?q=RoleCode = '##_HUMAN_CAPITAL_MANAGEMENT_INTEGRATION_SPECIALIST_JOB_ALL_DATA'

  5. Give the request the following headers:

    Note: Headers can be saved in presets in postman for reuse.

    Key Value
    REST-Framework-Version 4
  6. Click Send.

    The response should be 200 OK.

  7. Click Save.
  8. Copy the RoleId.

Assign a Role to a User Account

  1. In the response for Query Account by User Name click the collection link for the userAccountRoles.

  2. Give the request the name Assign a Role to a User Account.
  3. Click Save to ##_UserAccountsCollection.
  4. Specify the method as POST.
  5. Give the request the following headers:

    Note: Headers can be saved in presets in postman for reuse.

    Key Value
    Content-Type application/vnd.oracle.adf.resourceitem+json
    REST-Framework-Version 4
  6. Add the request body. None is selected by default, raw must be used to add content.

    Value replacements will need to be made in the body for your person id and user name.

    Request Body:

    {
      "RoleId": "123456"
    }
  7. Click Send.

    The response should be 201 Created.

  8. Click Save.

more informationWant to Learn More?