You can approve a work item request to complete the request by using the vRealize Automation REST API. To construct the approval command, you add work item and work item form details to a JSON file, and call that JSON file from the command line. Use a template to correctly format the JSON file content.

Input

Use the supported input parameters to control the command output.

Parameter

Description

URL

https://$host/workitem-service/api/workitems/workitem_ID

$host

Specifies the host name and fully qualified domain name or IP address of the vRealize Automation identity server.

$token

Specifies a valid HTTP bearer token with necessary credentials.

workitem_ID

Specifies the unique identifier of a work item. See Syntax for Listing Work Items.

Output

The command output contains property names and values based on the command input parameters.

Property

Description

Links

Specifies an array of link objects, each of which contains the following parts:

  • rel

    Specifies the name of the link.

    • Self refers to the object that was returned or requested. This property does not exist when you query for a single profile.

    • First, Previous, Next, and Last refer to corresponding pages of pageable lists.

    • Specifies the application or service that determines the other names.

  • href

    Specifies the URL that produces the result.

work itemNumber

Displays a reference number for the work item.

id

Specifies the unique identifier of this resource.

version

Displays the object version number.

assignees

Displays the list of work item assignees.

subTenantId

Optionally associates the work item with a specific business group granting users with management responsibilities over that business group permission to see the approval.

tenantId

Specifies the tenant ID for the work item.

callbackEntityId

Specifies the callback entity ID for the work item.

work itemType

Specifies the work item type for the work item.

completedDate

Specifies the date when the work item was completed.

assignedDate

Specifies the date when the work item was assigned.

createdDate

Specifies the created date of this instance.

assignedOrCompletedDate

Specifies the date to be displayed on UI.

formUrl

Specifies the URL from which the layout for this work item can be retrieved.

serviceId

Specifies the service ID that generated this work item instance.

work itemRequest

Specifies the corresponding work item request object.

status

Specifies the status of the work item.

completedBy

Specifies the principal ID of user who completed the work item.

availableActions

Contains a list of relevant work item actions.

Metadata

Specifies the paging-related data:

  • Size: Specifies the maximum number of rows per page.

  • totalElement: Specifies the number of rows returned.

  • totalPages: Specifies the total number of pages of data available.

  • Number: Specifies the current page number.

  • Offset: Specifies the number of rows skipped.

Example: curl Command

Approve a submitted machine request by specifying its work item ID and using a JSON file named approve.json to pass arguments to the command line.

curl --insecure -H "Content-Type: application/json" 
-H "Authorization: Bearer $token" 
https://$host/workitem-service/api/workitems/5e3e9519-78ea-4409-
a52c-e4aa3bc56511/actions/com.mycompany.csp.core.approval.action.approve 
--d @approve.json

Error Conditions

If the same request is submitted a second time, the following error response is received:

Command failed [Rest Error]: {Status code: 400}, {Error code: 12005} ,
{Error Source: null}, {Error Msg: Work item 5e3e9519-78ea-4409-a52c-e4aa3bc56511
is in COMPLETED state. Requested operation cannot be performed.}, {System Msg:
Work item 5e3e9519-78ea-4409-a52c-e4aa3bc56511 is in COMPLETED state. Requested
operation cannot be performed.}

If a user who is not authorized to approve the request submits the request, the following error response is received:

Command failed [Rest Error]: {Status code: 400}, {Error code: 12017} ,
{Error Source: null}, {Error Msg: User fritz@example.mycompany.com not authorized to
complete work item with ID 5e3e9519-78ea-4409-a52c-e4aa3bc56511.}, {System Msg:
User fritz@example.mycompany.com not authorized to complete Work item with id
5e3e9519-78ea-4409-a52c-e4aa3bc56511.}