OK so i'm basically suffering on the limitations of the K2 for SharePoint App.
Some vital things I'm having to create using PowerShell scripts (which execute REST calls to SharePoint) are stuff like list counts and viewing if Documents are open by users and locked for editing (not checked out).
For example - in SmartForms you're expected to retrieve all the items of a list (potentially thousands) to a page and then perform a count using a list aggregator in an expression. This is daft and not what the browser is intended for.
Anyway - I've decided to go down the route of creating a Service Instance for the REST Service Type. I've generated a Swagger Descriptor file based on the REST API method for "ItemCount" which returns a single JSON object coutaining the item count (surprisingly). The URI looks a bit similar to the following and works great in a browser, Fiddler and Postman:
/_api/web/Lists/getbytitle('MyList')/ItemCount
Now i'm able to create the Service Instance and generate the SmartObjects, however executing the method simply errors.
I can see the error in the K2 Host Server Logs but it's not particularly descriptive.
Does anyone know a way to troubleshooting this? Has anyone actually got this sort of thing working yet?