Monday, July 27, 2015

#424 Process Cloud Service - REST API - passing parameters Part I

In this post I look at a couple more of the PCS REST APIs -

I am using the following process for demo purposes -

What processes do I have?

This is just to recap -

try GET /process-definitions

curl -u phillip:welcome1 -H "Content-Type:application/json" -H "Accept:application/json" -X GET http://yourCloudInstance/bpm/api/1.0/process-definitions

Here is part of the response I get -


Here I see the processDefId is testing/SimpleOrderApp!1.0*soa_66f7e718-81cb-4a3e-

The serviceName is SimpleOrderProcess.service

The operation is start

Now, I have an instance of this process running -

I can get a user's tasks using the following API -

GET /tasks

curl -u phillip:welcome1 -H "Content-Type:application/json" -H "Accept:application/json" -X GET http://yourCloudInstance/bpm/api/1.0/tasks

Here I get the taskId, in this case, it is 200073.

Using the following REST API, I can add a comment to this task -

POST /tasks/taskId/comments

I try the following on Windows but get an Unexpected character error.
curl -u phillip:welcome1 -H "Content-Type:application/json" -H "Accept: application/json" -X POST -d '{"commentStr":"Good customer"}' http://yourCloudInstance/bpm/api/1.0/tasks/200073/comments

Note how I pass the parameters -
-d '{"commentStr":"Good customer"}'

The syntax is described in detail in the docs here

So how do I get over this error?
I simply do as described in the docs - I put the json snippet into a file.

I then revise the command as follows -

curl -u phillip:welcome1 -H "Content-Type:application/
json" -H "Accept:application/json" -X POST -d @NCaddComment.json http://yourCloudInstance/bpm/api/1.0/tasks/200073/comments

Let's look at the NCaddComment.json file -

I execute the command -

I check in Workspace -

And yes, I did execute the request twice.

Now I will reassign a task from phillip to renate.

Here are phillip's tasks -

Here is my reassign for the SimpleOrderApp (taskid 200079) -

curl -u phillip:welcome1 -H "Content-Type:application/json" -H "Accept:application/json" -X POST -d @NCreassignTask.json http://yourCloudInstance/bpm/api/1.0/tasks/200079/reassign

Here is the .json file -


Here is the execution -

I validate in Workspace - phillip now has only 1 task -

I login as renate -

I check the History -

No comments: