5 Replies Latest reply on Mar 15, 2018 1:30 PM by scarenci

    Starting jBPM process with parameters via REST API

    lauradp

      Hello everybody,

       

      I was trying to start a jBPM process via REST API providing a map of key-value parameters.

       

      I tried these url:

       

      * jbpmConsoleUrl + "/rest/runtime/" + deploymentId + "/process/" + processDefId + "/start";

      * jbpmConsoleUrl + "/rest/runtime/" + deploymentId + "/withvars/process/" + processDefId + "/start";

      * jbpmConsoleUrl + "/rest/runtime/" + deploymentId + "/withvars/process/" + processDefId + "/start" + "?" + encodedParameters;

       

      But in all cases jBPM process gets null parameters.

       

      If I launch process from jbpm-console and fill the predefined form parameters are correctly read.

       

      Can anyone help me?

       

      Laura

        • 1. Re: Starting jBPM process with parameters via REST API
          lauradp

          I solved this issue, the right URL was:

          jbpmConsoleUrl + "/rest/runtime/" + deploymentId + "/withvars/process/" + processDefId + "/start" + "?" + encodedParameters;

          but I omitted map_ prefix in parameters keys.

           

          HTH

           

          Laura

          • 2. Re: Starting jBPM process with parameters via REST API
            cjwallac

            Hi Laura,

             

            I was wondering since you were able to pass the parameters in the REST API, how do you then access the values in the jBPM Console? I would like to use them as process variables to assign the task to specific resources.

             

            You input is appreciated as I am not seeing much documentation... unless I have haven't looked in the right place yet.

             

            -CW

            • 3. Re: Starting jBPM process with parameters via REST API
              lauradp

              Hi, suppose you have defined var1 and var2 variables in your process.

               

              encodedParameters is built as map_var1=value1&map_var2=value2

               

              In this way you should be able to have value1 and value2 by mapping process variables on tasks parameters.

               

              HTH

               

              Laura

              • 4. Re: Starting jBPM process with parameters via REST API
                scarenci

                Hi Laura,

                 

                     I am trying to do the same, but its not working! Can you help me to understand what is going on? My parameters is not showing in the human task!

                 

                This is my code in angular:

                 

                   let url:any = "http://site/processos/rest/runtime/br.com.test:Formulario:1.4/withvars/process/Formulario.formulario/start";

                 


                   let body ={

                   nome:'start',

                   rg:'123456789'

                  }


                   let httpOptions = {

                   headers: new HttpHeaders({

                   'Authorization': 'Bearer ' + token,

                   'Accept':'application/json',

                   'Access-Control-Allow-Origin': '*',

                   'Content-Type':'application/json;charset=UTF-8'

                  })

                  };


                  this.http.post(url, body, httpOptions).subscribe(

                   res => {

                   //success

                   console.log("sucesso ao iniciar!");

                   alert(res);

                  },

                   err => {

                   console.log("Error ao iniciar:"+err);

                  }

                  );

                  });

                 

                In my flow i have setting a "data object" in the process and in the start. Is that correct?

                • 5. Re: Starting jBPM process with parameters via REST API
                  scarenci

                  Its working!

                   

                  I change the approach to primitive variable as string, int, etc.. and put in the name variable "map_" and in my flow a create a varible and set only in human task and not in start. My post was with x-www-form-urlencoded.

                   

                  I hope it helps someone