POST request from Web-service to Camunda (Apache-Tomcat 8) 7.5.0

Hello Folks,

I am building an Node-Express Web application which is totally based on API-calls to call Camunda process-engine for process-definition and others.

My web application locally is running on localhost:8082
While camunda apache-tomcat-8 is running on 8080.

Issues am facing:

  1. GET/POST requests doesnt work from MOZILLA and CHROME inspite of launching chrome after disabling web-security from cammand line.
    **Error: > **XMLHttpRequest cannot load http://localhost:8080/engine-rest/process-definition/key/invoice/submit-form/. No 'Access-Control-Allow-Origin' header is present on the requested resource. Origin 'http://localhost:8082' is therefore not allowed access. The response had HTTP status code 405**.**

  2. The second issue i am facing is that while the GET request works in IE but POST request still shows the status code 415 i.e. Unsupported format, while i checked sending the request to other domain engines, the request has been successful.

Kindly assist me
Camunda version - 7.5.0

Thanking in Advance
Shohil Sethia

Hi @Shohil_Sethia,

Have you already tried to enable CORS in the engine-rest-api? Therefore see

or

https://groups.google.com/d/msg/camunda-bpm-users/9pDJ7rMxFkc/grPLy0lQu4EJ

Cheers,
Roman

Hi @roman.smirnov
I have already done that, I have tried both the simple CORS filter and the typical config one present in the apache tomcat site.
Then too i am facing the same issue,
The same error.
Even after setting the filter the GET request itself doesn’t work, POST is next level.
while GET is working in IE but POST and DELETE are not working in IE too.
I added the CORS filter in web.xml in apache-tomcat-8/conf/web.xml
Thank You,
Shohil Sethia

Hi @Shohil_Sethia,

would it be an option for you to configure proxy pass on your http server?

https://httpd.apache.org/docs/current/mod/mod_proxy.html

if you use proxy, you don’t have to worry about CORS at all.

Hope that helps,
Askar

Hi @aakhmerov
Since the Web-Application i am building will be deployed globally, So i do not know whether it will be only inside the firm or will be accessible by client also.
In case if it is made the second way, The proxy configuration won’t work at client remote location.
My Web application is Running in Node-Express in which i am sending request via AngularJs HTTP.GET/POST.

> “use strict”;
> var camunda = angular.module(‘camunda’,[]);
> camunda.controller(‘camundaApi’,["$http","$rootScope", function($http,$rootScope) {
> $rootScope.obj={
> “variables”: {
> “creditor”: {“value”:“Niall”,“type”:“String”},
> “amount”:{“value”:“100”,“type”:“String”},
> “invoiceNumber”:{“value”:“123”,“type”:“String”}
> }
> };
> var parameter = {“variables”: {“creditor”: {“value”:“Niall”,“type”:“String”},“amount”:{“value”:“100”,“type”:“String”},“invoiceNumber”:{“value”:“123”,“type”:“String”}}};
> $http({
> method: ‘POST’,
> headers: ‘Content-Type: application/json’,
> url: ‘http://localhost:8080/engine-rest/process-definition/key/invoice/submit-form’,
> body: JSON.stringify({“variables”: {“creditor”: {“value”:“Niall”,“type”:“String”},“amount”:{“value”:“100”,“type”:“String”},“invoiceNumber”:{“value”:“123”,“type”:“String”}}})
> }).then(function(response) {
> // return response.data;
> console.log(response.data);
> });

> }]);

My Angular Controller code is given above. This sends request on every reload of the page.
After sending this request this gave NO ERROR, but the status code 415- Unsupported Format.
Even after i am converting my data into string. and when i don’t convert into string it throws following ERROR.
> Apache Tomcat/8.0.24 - Error reportH1 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:22px;} H2 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:16px;} H3 {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;font-size:14px;} BODY {font-family:Tahoma,Arial,sans-serif;color:black;background-color:white;} B {font-family:Tahoma,Arial,sans-serif;color:white;background-color:#525D76;} P {font-family:Tahoma,Arial,sans-serif;background:white;color:black;font-size:12px;}A {color : black;}A.name {color : black;}.line {height: 1px; background-color: #525D76; border: none;}

HTTP Status 415 - Cannot consume content type

type Status report

message Cannot consume content type

description The server refused this request because the request entity is in a format not supported by the requested resource for the requested method.


Apache Tomcat/8.0.24


Thanking in Advance
Shohil Sethia

@Shohil_Sethia, so unsupported format error means that you are most likely getting 404 on tomcat while sending request to your path and tomcat replies to you with standard page, which is not a JSON but a text.

Apart from that I would like to make sure that you understand following concept, given that

  1. node+express - server side code which serves content for your frontend (AngularJS)
  2. frontend (AngularJS) executed in users browser

In general it is not a problem to send requests from one backend system to another, i.e. from your express server to camunda server. But there is a problem when user does that from his browser. This is why a clean solution would be for browser to request your express server, which will then proxy request to camunda.

Does that help you?
Askar.

Hi @aakhmerov @roman.smirnov

When i am sending request from NodeJs server to Camunda apache-tomcat-8 ,this is the error i am getting even after using CORS typical confi filter in apache-tomcat-8/conf/web.xml (inserted at the top):
_> (node) http.createClient is deprecated. Use http.request instead.

Status: 405
Headers: { server: ‘Apache-Coyote/1.1’,
allow: ‘HEAD, GET, OPTIONS’,
‘content-length’: ‘0’,
date: ‘Tue, 22 Nov 2016 12:38:27 GMT’ }

To: @aakhmerov
I am sorry, i could not understand,
Are you telling to send request from express server to camunda server. ??
But my API code is in AngularJs ,so how will tell browser to tell my server to send proxy request to camunda ??
Also if i am sending request from my nodeJs server to camunda server ,how i am supposed to do that ??
It would be greatly helpfull if you could give me a sample.
Thanking in advance
Shohil Sethia

@roman.smirnov and @aakhmerov @system
Thank you all,
It seems the the POST request is going but it shows this error:

<body><h1>HTTP Status 415 - Cannot consume content type</h1><div class=

“line”>

type Status report

message Cannot consume content type

description The server refused this request because the request entity is in a format not
supported by the requested resource for the requested method.


Apache Tomcat/8.0.24

key note:

  1. I tried sending json after minifying it.
  2. i also tried sending it as a string by JSON.stringify({…}).
  3. In some cases i got language is not supported by juel, (I read about it and found that two concepts are there JUEL and FEEL ; but still could not figure where am i going wrong.
  4. I have tried sending that request on other sample domains, It seems to be working fine, Only struggling with camunda-aache-tomcat-8.0.24 (apache/coyote 1.1).

Any help would be greatly appreciated
Thanking all in Advance
Shohil Sethia

Hi Shohil, were able to solve this ?