REST API Bonita 6.x - Auth - Error while logging in on the engine API
Server Enviroment
- CentOS 6.4 (Final);
- Java(TM) SE Runtime Environment (build 1.7.0_45-b18);
- BonitaBPMCommunity-6.2.0-Tomcat-6.0.37 (bundle);
- Postgresql 9.2.6;
REST client
package com.mkyong.rest.client;
import java.io.BufferedReader;
import java.io.IOException;
import java.io.InputStreamReader;
import java.net.MalformedURLException;
import org.apache.http.HttpResponse;
import org.apache.http.client.methods.HttpPost;
import org.apache.http.entity.StringEntity;
import org.apache.http.impl.client.DefaultHttpClient;
public class ApacheHttpClientPost {
// http://localhost:8080/RESTfulExample/json/product/post
public static void main(String[] args) {
try {
DefaultHttpClient httpClient = new DefaultHttpClient();
//HttpPost postRequest = new HttpPost(
// "http://localhost:8080/RESTfulExample/json/product/post");
HttpPost postRequest = new HttpPost("http://
//StringEntity input = new StringEntity(
// "{\"qty\":100,\"name\":\"iPad 4\"}");
StringEntity input = new StringEntity("{\"username\":\"myusername\",\"password\":\"mypassword\",\"redirect\":\"false\"}");
input.setContentType("application/json");
postRequest.setEntity(input);
HttpResponse response = httpClient.execute(postRequest);
if (response.getStatusLine().getStatusCode() != 200) {
throw new RuntimeException("Failed : HTTP error code : "
+ response.getStatusLine().getStatusCode());
}
BufferedReader br = new BufferedReader(new InputStreamReader(
(response.getEntity().getContent())));
String output;
System.out.println("Output from Server .... \n");
while ((output = br.readLine()) != null) {
System.out.println(output);
}
httpClient.getConnectionManager().shutdown();
} catch (MalformedURLException e) {
e.printStackTrace();
} catch (IOException e) {
e.printStackTrace();
}
}
Output server
Output from Server ....
/* Add url hash to form action url */
$(document).ready(function() {
var form = $('#LoginForm');
form.attr('action', form.attr('action') + encodeURI(window.location.hash));
});
Welcome to Bonita BPM Portal
bonita.2014-01-15.log
gen 15, 2014 9:48:48 AM org.bonitasoft.console.common.server.login.datastore.LoginDatastore login
Grave: Error while logging in on the engine API.
---
Of course user myuser : mypassword is in db of the engine.
What's wrong?
Thanks in advance
Comments
did you use the technical account (install / install) to create the first admin users ?
Yes I did
If I understand, you try to log in through the API, via a third party application? can you log in with Bonita BPM Portal, to check if the problem is with your script, or with Bonita.
Unfortunately, I can login to the portal with the same credentials. The problem is my script. If I understand the portal is "like" third part application (because use REST API). Do you know where I can find the code?