Introduction
In IriusRisk, the unique ID of a business unit cannot be changed directly from the user interface after it has been initially created. If you find yourself in a situation where you need to modify the unique ID of a business unit, you may be concerned about the time-consuming process of manual deletion, recreation of the business unit, and user reassignment. However, there is a more efficient solution: leveraging the IriusRisk API to streamline this task. In this article, we will guide you through the process of changing the unique ID of a business unit using the IriusRisk API.
Use Case: Streamlining Business Unit ID Changes Using the IriusRisk API
Instead of going through the process of manually gathering user information, deleting and recreating business units, and reassigning users, you can take advantage of the IriusRisk API to achieve the same goal with significantly less effort. The API endpoints we'll utilize enable you to list users belonging to a business unit, delete a business unit, create a new business unit, and assign users to it. By combining these API calls, you can efficiently change the unique ID of a business unit and maintain user assignments. Let's walk through the steps:
-
List Users in the Existing Business Unit: Use the following API call to retrieve a list of users belonging to the business unit whose ID you want to change:
curl -X 'GET' \ 'https://<endpoint>.iriusrisk.com/api/v1/businessunits/<business_unit>/users' \ -H 'accept: application/json' \ -H 'api-token: <api_token>' | jq -r '.[].username'
-
Delete the Existing Business Unit: Next, delete the current business unit using the DELETE API call:
curl -X 'DELETE' \ 'https://<endpoint>.iriusrisk.com/api/v1/businessunits/<business_unit>' \ -H 'accept: application/json' \ -H 'api-token: <api_token>'
-
Create a New Business Unit: Now, create a new business unit with the desired unique ID using the POST API call:
curl -X 'POST' \ 'https://<endpoint>.iriusrisk.com/api/v1/businessunits' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -H 'api-token: <api_token>' \ -d '{ "ref": "<business_unit_uniqueID_2>", "name": "<business_unit_name_2>", "desc": "<business_unit_desc_2>" }' | jq
-
Assign Users to the New Business Unit: Finally, use the PUT API call to assign the list of users to the newly created business unit:
curl -X 'PUT' \ 'https://<endpoint>.iriusrisk.com/api/v1/businessunits/<business_unit_name_2>/users' \ -H 'accept: application/json' \ -H 'Content-Type: application/json' \ -H 'api-token: <api_token>' \ -d '{ "usernames": [ "<username_1>", "<username_2>", "<username_3>" ] }' | jq
Conclusion
Changing the unique ID of a business unit in IriusRisk doesn't have to be a time-consuming process involving manual steps. By utilizing the power of the IriusRisk API, you can efficiently achieve this task with a series of API calls. This approach streamlines the process, reduces errors, and saves you valuable time. For more detailed setup instructions and information, feel free to refer to our API Articles. Should you need assistance with generating an API key, check out the guide on How to Generate an API Key.
Remember, the API can be called through various methods, including cURL and Postman. For this article, we've provided cURL examples, but feel free to explore other options as well.
Comments
0 comments
Please sign in to leave a comment.