Hi,
I am new to Bonita BPM. I have managed to create a process and run it successfully thru Bonita Studio.
But i am not able to start the process instance using REST APIs (http://localhost:1904/bonita/API/runtimeAPI/instantiateProcessWithVariables/EmployeeInformation--1.0). It gives 401 error. On searching the net on this issue found that we need to configure REST details in JAAS, but not able to get thru even after configuring JAAS.
Also there is mention of bonita-server-rest.war in many of the replies on similar issue, but couldnt really find this war for 7.0.0 version. Not sure if its still valid for this version.
Can anybody please guide me thru on how to make REST APIs work?
Thanks in advance.
Anant
Hi,
To start an instance of a process (aka. case) you should use the following REST API resource:
POST | /bonita/API/bpm/case
If you don’t need to specify variables then you should be good with this payload:
{ "processDefinitionId":"5777042023671752656" }
Otherwise you should send something like:
{
"processDefinitionId":"5777042023671752656",
"variables":[
{
"name":"stringVariable",
"value":"aValue"
},
{
"name":"dateVariable",
"value":349246800000
},
{
"name":"numericVariable",
"value":5
}
]
}
REST API documentation for the case resource can be found here: http://documentation.bonitasoft.com/bpm-api-1#case
I would try with this resource before digging further with custom JAAS configuration.
Hope this helps.
Truc
Hi Truc,
Thanks a lot for your reply.
I tried your suggestion, but its still giving 401 error. I think there is no issue in the way REST APIs are being called, but i am missing some configuration at my server end that enables the REST server to accept the request.
I even tried using basic authorization using restuser / restbpm credentials but its still the same.
Regarding the JAAS configuration, i read in many replies that there a need to make the below entry to make REST APIs able to accept the requests
BonitaRESTServer {
org.ow2.bonita.identity.auth.BonitaRESTServerLoginModule required logins=“restuser” passwords=“restbpm” roles=“restuser”;
};
I tried putting this entry in <BPM_Studio_Home>\workspace\tomcat\bonita\client\platform\conf\jaas-standard.cfg file as well, but still not able to get thru.
Any other suggestions please?
Thanks in advance,
Anant
Hi Truc,
I am using 7.0.0 version.
I think the issue might be with the JSESSIONID, i read that we need to use loginservice API first before calling any other REST APIs and pass the returned JSESSIONID to futher API calls. Is my understanding correct? Or is there any other way?
But somehow even the loginservice is not working. Even though i get 200 response the message says “Unable to log in. Please check your username and password.”. Where as when i pass the same data in the browser with URL “http://localhost:8080/bonita/loginservice?username=xxxx&password=yyyy&redirect=true” it logs in.
Tried passing the data in header as well as payload, but the result is the same. I am using Google Chrome’s Advanced Rest Client App for testing. But i would be using this finally from Talend ESB thru tRestClient connector.
Any clue on what might be the issue with loginservice?
Thanks in advance,
Anant
Hi Truc,
It worked for me as well now.
The issue was with the Content-Type that i was setting while making the REST calls. It works only with “application/x-www-form-urlencoded” type.
I am now able to use the JSESSIONID and make other REST API calls successfully.
Thanks a lot for your help.
Anant.
Hi, how i can implement this using PHP CURL?
Hello.
This link is no longer available. http://documentation.bonitasoft.com/bpm-api-1#case
I'm having trouble creating a case with the rest api.
First I log in ok with the rest api
and then following these examples i cant create the case
{
"processDefinitionId":"5777042023671752656",
"variables":[
{
"name":"stringVariable",
"value":"aValue"
},
{
"name":"dateVariable",
"value":349246800000
},
{
"name":"numericVariable",
"value":5
}
]
}
I follow these suggestions and I get a 401, unauthorized. I use postman to test the rest api.
some help ?
Hi Anant,
Which version of Bonita BPM are you using? My comment applies to Bonita BPM 7 and I confirm there should be nothing to configure in order to enable REST APIs.
Hi,
/loginservice worked for me using Chrome’s Advanced Rest Client App
Once logged in I tested with a sample REST API call to /API/system/session/unusedid which was successful.
The “Unable to log in. Please check your username and password.” message lets me think there is an issue with the user’s credentials somehow. Can you double check user/password is correct?
HTH