Handle a successful sales system API response
If the API call is successful, you want to release the current work item as done (this indicates the work item was processed successfully):
consumer.robot
:
*** Settings ***
Documentation Inhuman Insurance, Inc. Artificial Intelligence System robot.
... Consumes traffic data work items.
Resource shared.robot
*** Tasks ***
Consume traffic data work items
For Each Input Work Item Process traffic data
*** Keywords ***
Process traffic data
${payload}= Get Work Item Payload
${traffic_data}= Set Variable ${payload}[${WORK_ITEM_NAME}]
${valid}= Validate traffic data ${traffic_data}
IF ${valid} Post traffic data to sales system ${traffic_data}
Validate traffic data
[Arguments] ${traffic_data}
${country}= Get Value From Json ${traffic_data} $.country
${valid}= Evaluate len("${country}") == 3
RETURN ${valid}
Post traffic data to sales system
[Arguments] ${traffic_data}
${status} ${return}= Run Keyword And Ignore Error
... POST
... https://robocorp.com/inhuman-insurance-inc/sales-system-api
... json=${traffic_data}
Handle traffic API response ${status}
Handle traffic API response
[Arguments] ${status}
IF "${status}" == "PASS" Handle traffic API OK response
Handle traffic API OK response
Release Input Work Item DONE
The Handle traffic API response
keyword takes the status as an argument. If the status is PASS
(indicating successful keyword execution - essentially a successful API request), the Release Input Work Item
keyword releases the work item as DONE
.
You want to release all the work items your robot processes - both the successful and the unsuccessful.