robocorp / rpaframework

Collection of open-source libraries and tools for Robotic Process Automation (RPA), designed to be used with both Robot Framework and Python
https://www.rpaframework.org/
Apache License 2.0
1.13k stars 217 forks source link

Bug in Process.py function "list_process_work_items" #1095

Open gio1984 opened 11 months ago

gio1984 commented 11 months ago

The function list_process_work_items doesn't retrieve all work items if they are more than 100. Additionally, it applies the filter after the request, so if it searches for "FAILED" items and the first 100 work items are all in the "COMPLETED" state, it will return an empty list. The API documentation says that the maximum value for "size" is 100 and to use "cursor" to retrieve the next pages. (https://robocorp.com/docs/control-room/apis-and-webhooks/api/process)

Probably, it could be fixed like this: data = None while True: response = requests.get(url=url_list_workitems, params=params, headers=calls_headers) response_json = response.json() if data == None: data = response_json["data"] else: data = data + response_json["data"] if response_json["nextCursor"] == None: break else: params["cursor"]= response_json["nextCursor"]

cmin764 commented 10 months ago

Hi and thx for the report. Indeed, our RPA Framework Process library doesn't support pagination and server-side filtering, but your proposal looks valuable, so we'd be happy if you can help us with a PR. (here's our Dev Guide to get started)


Meanwhile, we just released a new API and we're working on wrapping it into a Python client in Robo, but this will take some time until it gets released and even backported here as well.