Add a Role to a User
You want to assign some additional tasks to your user. However, those tasks are associated with specific roles that aren't yet assigned to your user. In this use case, you will learn how to search for a specific role and assign it to a user. You may have to obtain the necessary approvals before actually assigning the role to the user.
First, identify the role that you want to assign, and then identify the user.
- Use cURL and
eq
filter parameter with thename
field to query. In this example, the queried role name isORA_PER_HUMAN_RESOURCE_ANALYST_JOB
and the role ID returned in the response is55361929311C580B560EB8BA5C4C1886
.curl -i -u "<username>:<password>" -H "Content-Type: application/json" -X GET -d <payload> https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Roles?filter=name eq "ORA_PER_HUMAN_RESOURCE_ANALYST_JOB"
Sample Response Payload
{ "itemsPerPage": 1, "startIndex": 1, "Resources": [ { "id": "55361929311C580B560EB8BA5C4C1886", "meta": { "created": "2009-05-12 11:27:39.226", "lastModified": "2016-11-17 17:00:46.000", "location": "https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Roles/55361929311C580B560EB8BA5C4C1886" }, "schemas": [ "urn:oracle:apps:scim:schemas:fa:1.0:Role" ], "name": "ORA_PER_HUMAN_RESOURCE_ANALYST_JOB", "displayName": "Human Resource Analyst", "description": "Performs duties of a human resources analyst.", "category": "JOB", "members": [ { "value": "258D2199A0BB1AA3E050F00A185B018E" }, { "value": "6424EF8136C0C20F12466257D3540E9C" } ] } ] }
- Now that you have the role ID, search for
and get the user ID. Use cURL and
eq
filter parameter with theusername
field to query. In this example, queried user name isCUST_CONTRACT_MGR_OPERATIONS
and the user ID returned in the response is5A25572D96277A00C0547E3A715EF682
.curl -i -u "<username>:<password>" -X GET https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Users?filter=username eq "CUST_CONTRACT_MGR_OPERATIONS"
Sample Response Payload
{ "itemsPerPage": 1, "startIndex": 1, "Resources": [ { "id": "5A25572D96277A00C0547E3A715EF682", "meta": { "created": "2009-05-25 00:00:00.000", "lastModified": "2015-12-14 10:15:48.291", "location": "https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Users/5A25572D96277A00C0547E3A715EF682" }, "schemas": [ "urn:scim:schemas:core:2.0:User" ], "userName": "CUST_CONTRACT_MGR_OPERATIONS", "name": { "familyName": "Black", "givenName": "Sophie" }, "displayName": "Sophie Black", "emails": [ { "value": "CUST_CONTRACT_MGR_OPERATIONS@dummy.oracle.com", "type": "W", "primary": true } ], "roles": [ { "id": "4EB6B72643872425B6BE573B531ABC6B", "value": "OKC_CUSTOMER_CONTRACT_MANAGER_VISION_OPERATIONS_DATA", "displayName": "Customer Contract Manager - Vision Operations", "description": "Customer Contract Manager for Vision Operations" }, { "id": "40C4AE052EC2582286A6A0FB1514656C", "value": "ORA_PER_EMPLOYEE_ABSTRACT", "displayName": "Employee", "description": "Identifies the person as an employee." }, { "id": "05E9F3576995F83E74EB3818FDCA8639", "value": "ORA_PER_LINE_MANAGER_ABSTRACT", "displayName": "Line Manager", "description": "Identifies the person as a line manager." } ], "active": true } ] }
- Using cURL, submit an
ADD
operation of the PATCH request to assign the role to the user. In this example, add the55361929311C580B560EB8BA5C4C1886
role ID to the5A25572D96277A00C0547E3A715EF682
user ID.curl -i -u "<username>:<password>" -H "Content-Type: application/json" -X PATCH -d { "schemas": [ "urn:oracle:apps:scim:schemas:fa:1.0:Role" ], "members":[{"value":"5A25572D96277A00C0547E3A715EF682", "operation":"ADD"}] } https://servername.fa.us2.oraclecloud.com/hcmRestApi/scim/Roles/55361929311C580B560EB8BA5C4C1886
The role gets assigned to the user.