cancel
Showing results for 
Search instead for 
Did you mean: 

Error deploying with REST API in 5.16.4

jrnorrisjr
Champ in-the-making
Champ in-the-making
After upgrading from 5.16.3 to 5.16.4 I can no longer deploy a file via the REST API.  The error says it's not a valid file type although it is as shown in some debugging out:


ActivitiServiceImpl.deployProcessDefinition() - file being deployed = c:\activiti-tempfiles\MyProcess.bpmn20.xml
ActivitServiceImpl.deployProcessDefinition() - activiti response = {"message":"Bad request","exception":"File must be of type .bpmn20.xml, .bpmn, .bar or .zip"}


This is a code snippet where the post is being made, name is "MyProcess" and the file object is the one that printed the path in the debug statement:


MultipartEntityBuilder entityBuilder = MultipartEntityBuilder.create();
entityBuilder.setMode(HttpMultipartMode.BROWSER_COMPATIBLE);
entityBuilder.addBinaryBody(name, file, ContentType.DEFAULT_BINARY, name + ".bpmn20.xml");
HttpEntity entity = entityBuilder.build();
httpPost = new HttpPost(activitiUrl);
httpPost.setEntity(entity);
response = client.execute(httpPost, context);

Anyone else having this issue?
8 REPLIES 8

jbarrez
Star Contributor
Star Contributor
Hmmm, our test has remained the same for the old and the new version: https://github.com/Activiti/Activiti/blob/master/modules/activiti-rest/src/test/java/org/activiti/re...

Could you check how it is done in this test and how it is different from what you do?

jrnorrisjr
Champ in-the-making
Champ in-the-making
Sure, I took a look there before but I'll try your approach tomorrow.  I didn't copy that code because it is using the ReflectUtil class from the engine which we are not including.  Again, the above code works in the previous version which we reverted to.

jrnorrisjr
Champ in-the-making
Champ in-the-making
I took a look through your test code and basically in the end it is using the addBinaryBody method call with a byte[] instead of a file object and is setting the content-type to application/xml instead of application/octec-stream.  I modified my code to do the same so the httpPost.setEntity is doing exactly what your test does.  I still get a 400 bad request error although I now don't see the message about the status error being an incorrect file type.  I then changed my code back to the original and now I'm only getting the bad request message and nothing about the file type.  Strange …

trademak
Star Contributor
Star Contributor
The issue was that it used the name field of the multipart file instead of the filename. I've committed a fix so that the filename is used if it exists. That should fix your issue, let me know if you are still running into issues.

Best regards,

jrnorrisjr
Champ in-the-making
Champ in-the-making
Thanks for the update Tijs.  We will give it a try.

leac87
Champ in-the-making
Champ in-the-making
Hi, I think I'm having the same issue with 5.16.4, is the fix that you commited available? where can I find it?
Thanks!

trademak
Star Contributor
Star Contributor
It's available on the current master not in 5.16.4. It will be included in the 5.17 release that we'll do in few weeks.

Best regards,

chandan_t81
Champ in-the-making
Champ in-the-making
I am also facing the same issue when I try to deploy a process from a Chrome REST client. Please help what to do?