REST API calls with HTTP basic Authentication

1
0
-1

Hello,

I'm trying to write a script to init a Bonita server automatically. The aim of this script is to :
- import my organization
- import my bdm
- import processes
- import an application and related pages

First of all, i'd like to create a user with the 'install' technical user. To do this, I'm doing an HTTP Post request on http://localhost:8080/bonita/API/identity/user/. I set Content-Type to application/json, set Authorization to use the 'install' user and pass the following body :
{"enabled":"true","userName":"deploy","password":"deploy","password_confirm":"deploy","firstname":"Deploy","lastname":"User"}

When I make this HTTP request from REST Client, it works. When I make this HTTP request from my nodeJS script, I get a 401 HTTP status (this script uses request module). I've also tried to make my request with curl but got the same result (401).

In my script, I've also tried to make a call to loginservice to get the Bonita cookie and pass this cookie to my POST request but it does'nt work either.

I'm using Bonita 7.2.2.

Is it possible to make a call to Bonita REST API using basic HTTP authentication ?
Do you a way to do what I want to do ? Perhaps, you have an example...

Thanks in advance for your help.

Mickaël

2 answers

1
+1
-1

I like the idea of doing it this way, but like you found various problems. In the end we used a third party automation tool to do this for us.

Extract the zip
Start the server
Open browser
Login
do the actual "clicks" to upload the organization etc.
logout
close browser
close server and restart

regards
Seán

PS: If this reply answers your question, please mark as resolved.

1
0
-1

Hello,

I finally get it to work. In nodejs request module, there is a "jar" parameter" to keep cookies between two requests. With this parameter to true in my 2 requests (login, create user), it works.

However, it doesn't explain why it does'nt work with a Basic HTTP authentication.

Notifications