CORS Issue when doing a post call to the DMN decision

Hi All,
I am doing a post call to the DMN decision with the decision values in json format but when doing the post call to my localhost:8080 where the camunda DMN decision is running i am facing CORS issue. Below is the code

var data = JSON.stringify(
        {
            "season":
            {
                "type": "string",
                "value": "Spring"
            },
            "children":
            {
                "type": "boolean",
                "value": true
            },
            "weather":
            {
                "type": "string",
                "value": "Sunny"
            },
            "time":
            {
                "type": "string",
                "value": "morning"
            },
            "interest":
            {
                "type": "string",
                "value": "activity"
            }
        },
        false, 2
    );

    $('.json .language-json .request').text(data);
    $('.json').show();

    $.ajax
        ({
            type: 'POST',
            url: apiUrl + 'decision-definition/example-berlin:1:4adc11a5-3c2a-11e9-942f-0242977e95b7',
            data: data,
            dataType: 'json',
            contentType: 'application/json; charset=utf-8',
            success: function (data) {

                $('.json .language-json .response').text(JSON.stringify(data, null, 2));

                $('#recommendationsContainer').show();

                if (data.rules.length > 0) {

                    $.each(data.rules, function (key, value) {

                        $('#recommendations').append(''
                            + '' + value.outputs.recommendation.value + ''
                            + 'More Info');
                    });

                } else {
                    $('#recommendations').append(''
                        + 'Sorry, no ideas for this combination :-(');
                }
            }
        });

This the

apiUrl = “http://localhost:8080/camunda/app/cockpit/default/

which i am hitting and facing the CORS issue but i hit the below URL

apiUrl = “https://dmn.lab.camunda.com/api/v1/

i am not facing any issues. Can someone point me what i doing wrong here.

Thanks in advance

Hi @Kishan_R,

you are using the REST API embedded in the Webapps. This API is not meant to be used to perform custom requests. Please instead deploy the REST API artefact separately.

Cheers,
Tassilo

Ok @tasso94 can you guide me is there any link which i can refer to do it.

Thanks
Kishan

Hi @Kishan_R,

setting up the engine-rest artefact is highly dependant of your environment. In which container do you use Camunda BPM (e. g. Spring Boot, Docker, Tomcat, etc.)?

Cheers,
Tassilo

I am running the server on wildfly.

starting camunda BPM 7.10.0-alpha4 on Wildfly Application Server 10.1.0.Final

  JBoss Bootstrap Environment

  JBOSS_HOME: ./server/wildfly-10.1.0.Final

  JAVA: /usr/lib/jvm/java-8-oracle/bin/java

  JAVA_OPTS:  -server -Xms512m -Xmx768m -XX:MetaspaceSize=128M -XX:MaxMetaspaceSize=256m -Djava.net.preferIPv4Stack=true -Djboss.modules.system.pkgs=org.jboss.byteman -Djava.awt.headless=true

Please let me know if you need more information. I am need to run the above in node for my understanding i am doing with jquery.

Hi @Kishan_R,

if you are using Camunda BPM full distribution, the engine-rest artefact is already deployed.
You can reach it under http://localhost:8080/engine-rest

Cheers,
Tassilo

Hi @tasso94,
I am using Camunda BPM, i just need to get the response directly from the decision table (DMN table) upon the value passed as data i should the response of it from the DMN decision table. So is there a way to do that, if so please guide me @tasso94.

Thanks
Kishan R