Helo,
I’m trying to upload file in bonita to create a ‘bonita temporaly file’.
The url is : http://:/bonita/portal/resource/process///API/formFileUpload
To execute this call, we need to be connect and add bonita token and bonita cookie in the POST call.
So, i’m trying to do it like that ( with OKHttp ):
OkHttpClient client = new OkHttpClient();
MediaType mediaType = MediaType.parse("multipart/form-data; boundary=----WebKitFormBoundary7MA4YWxkTrZu0gW");
RequestBody body = RequestBody.create(mediaType, file);
Request.Builder requestBuilder = new Request.Builder()
.url("http://<server>:<port>/bonita/portal/resource/process/<process>/<verrsion>/API/formFileUpload")
.post(body)
.addHeader("Content-Type", "multipart/form-data")
.addHeader("Accept", "application/json")
.addHeader("X-Bonita-API-Token", authenticationService.extractBonitaTokenFromCookie(authenticationResult))
.addHeader("cache-control", "no-cache");
for (String aa :
authenticationResult.getHeaders().get("Set-Cookie")) {
requestBuilder.addHeader("Cookie", aa);
}
Request request = requestBuilder
.build();
Response response = client.newCall(request).execute();
ResponseBody result = response.body();
authenticationResult.getHeaders().get(“Set-Cookie”) contain a list with:
- JSESSIONID=6ECBA8154F52E34C796FBAB2569702C5; path=/bonita;
- bonita.tenant=1;
- X-Bonita-API-Token=321a90a4-dce9-4b5e-ab00-97f7ee2aded0;
When i’m doing that, i have an HTTP-200 but nothing in my body.
And when i’m doing this in Postman, i’ve got a response like:
{"filename":"Shema.docx","tempPath":"tmp_7955574425971529233.docx","contentType":"application\/vnd.openxmlformats-officedocument.wordprocessingml.document"}
I need to do this in order to instantiate a form.
Someone can help me ?