First attempt at sales system API integration
Time to start the conversation with the sales system API. As an icebreaker, you implement a POST request:
consumer.robot:
- The
IFcondition checks if the data is valid. If yes, thePost traffic data to sales systemkeyword is called. If not, nothing is done. - The
POSTkeyword posts the JSON payload to the sales system API endpoint URL. - You add the
RPA.HTTPlibrary to theshared.robotand remove the library import from theproducer.robot(DRY!).
When you run the consumer task, eventually, one of the POST requests will fail with an exception:
HTTPError: 500 Server Error: Internal Server Error for url: https://robocorp.com/inhuman-insurance-inc/sales-system-api
This is probably the issue that the sales system API team mentioned. Sometimes the API call fails.
Currently, your robot gives up immediately after hitting an exception. You would like the robot to continue posting the traffic data as long as data is available, ignoring the failed attempts.
You decide to ignore the exceptions for now and improve the exception handling a bit later (small steps!):
consumer.robot:
The Run Keyword And Ignore Error keyword ignores any errors and returns two values. The first one is either a string PASS or FAIL, depending on the status of the executed keyword. The second value is either the return value of the keyword or the received error message.
You run the consumer task. The log shows both the successful and failed requests:
Successful request:
${status} = PASS
{return} = <Response [200]>
Failed request:
${status} = FAIL
${return} = HTTPError: 500 Server Error: Internal Server Error for url: https://robocorp.com/inhuman-insurance-inc/sales-system-api