You get that error message when the name of the role you provided as input doesn't actually exist in K2.
Note that if you just created the role, you might have to wait for the identity cache to refresh before using this method.
The identity cache was the problem in this case. I tried the Get Least Work method of the TaskAllocationRoleMethods SmartObject again today and now it reutrns data. So obviously the cache was update since the last time I tried.
Is there a way to force the cache to update ?
What I saw now is that when I execute the Get Least Work method it only returns the one user everytime (say for example user A).
Scenario:
I have "user A" and "user B" in a "TestRole". "User A" has 2 work items at the moment and "User B" has no work items. Should the Get Least Work method not return "User B" because he has no work items at all ? For some reason the SmartObject doesn't return "User B". Does this method only work with users who have one or more work items ?
See here for more info about the K2 identity cache, including SQL to force an update of a particular identity cache item, or the entire cache.
I don't know exactly how the internals of that method work. It's possible it only looks at items that are currently open (meaning a user has claimed a destination slot). K2 Support might be able to give you more details about that.