14 Replies Latest reply on Feb 19, 2014 4:34 AM by swiderski.maciej

    REST API

    faraon79

      Hello,

       

      I found REST API to communicate with engine but not sure what should be added as a preffix, e.g.


      /deployment/

      /task/{taskId}/claim

      /deployment/{deploymentId}/deploy


      I've tried something like:


      localhost:8080/jbpm-console/deployment


      but getting 404 error


      Could anyone send an example how to use this REST API and correct JSON body for POST requests.

      Actually I don't understand how to deploy(POST) BPMN definition which is in XML format as a JSON request.


      Thanks in advance




        • 1. Re: REST API
          faraon79

          User guide mention sample url like below:

           

          http://localhost:8080/kie-wb/rest/runtime/myproject/process/wonka.factory.loompa.hire/start?map_kEy=vAlue

           

          Is kie-wb a module it is not shipped with jBPM install package?

           

          EDIT:

           

          I tried something like this:

           

          /jbpm-console/rest/deployment/

           

          but HTTP status 500 occurs:

           

          org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.core.HttpHeaders

          org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:53)

          com.sun.proxy.$Proxy207.getRequestHeaders(Unknown Source)

          org.kie.services.remote.rest.ResourceBase.getVariant(ResourceBase.java:115)

          org.kie.services.remote.rest.exception.DescriptiveExceptionHandler.toResponse(DescriptiveExceptionHandler.java:66)

          org.kie.services.remote.rest.exception.DescriptiveExceptionHandler.toResponse(DescriptiveExceptionHandler.java:25)

          sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

          sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

          sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

          java.lang.reflect.Method.invoke(Method.java:597)

          org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:44)

          org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)

          org.kie.services.remote.rest.exception.DescriptiveExceptionHandler$Proxy$_$$_WeldClientProxy.toResponse(DescriptiveExceptionHandler$Proxy$_$$_WeldClientProxy.java)

          org.jboss.resteasy.core.SynchronousDispatcher.executeExceptionMapper(SynchronousDispatcher.java:324)

          org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:229)

          org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:123)

          org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

          org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

          javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

          org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)

          org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)

          org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)

          org.jbpm.designer.web.filter.impl.PluggableFilter.doFilter(PluggableFilter.java:70)

          org.uberfire.security.server.UberFireSecurityFilter.doFilter(UberFireSecurityFilter.java:266)

           

          Is it good path but configuration issue?

          • 2. Re: REST API
            cegi

            I don't see a REST call having "deployment" but "{deploymentId}" which is the deployment name you see in the "Deploy" section in jbpm-console after making at least one process deployment.

            In the "demo" repository you can find in "jbpm-playground" a project called HR with a process called hiring, in this case you would start a process with a call like this:

             

            URL

            http://localhost:8080/jbpm-console/rest/org.jbpm:HR:1.0/process/hiring/start


            Payload (body of the call)

            map_name=Joe+Smith

             

            Hope this helps.

            1 of 1 people found this helpful
            • 3. Re: REST API
              faraon79

              Thanks for the answer.

              I'm using REST API from here .

              Actually I think the issue is an incorrect http header. I tried:

               

              Authorization: Basic auth_string

              Accept: application/xml

               

              but still get the same server response:

               

              status 500:

              org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.core.HttpHeaders

              org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:53)

              ....

              • 4. Re: REST API
                swiderski.maciej

                could you post complete code you use to interact with REST api?

                 

                That could help to diagnose if the issue is with sample code or rest api.

                 

                HTH

                • 5. Re: REST API
                  faraon79

                  There is nothing to send. I've got demo install on remote server without any changes, and just call rest api, e.g.

                   

                  GET

                  {host}:8080/jbpm-console/rest/deployment

                   

                  Header:

                  Authorization: Basic a3Jpc3Y6a3Jpc3Y=

                  Accept: application/xml

                   

                  Now I see in jBPM6 user guide that there can be no "/deployment" path, but when use "/repositories" instead server response doesn't change.

                   

                  Complete server response:

                   

                  <html>

                      <head>

                          <title>JBoss Web/7.0.13.Final - Error report</title>

                          <style>

                              <!--H1 {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;}HR {color : #525D76;}-->

                          </style>

                      </head>

                      <body>

                          <h1>HTTP Status 500 - </h1>

                          <HR size="1" noshade="noshade">

                              <p>

                                  <b>type</b> Exception report

                              </p>

                              <p>

                                  <b>message</b>

                                  <u></u>

                              </p>

                              <p>

                                  <b>description</b>

                                  <u>The server encountered an internal error () that prevented it from fulfilling this request.</u>

                              </p>

                              <p>

                                  <b>exception</b>

                                  <pre>org.jboss.resteasy.spi.LoggableFailure: Unable to find contextual data of type: javax.ws.rs.core.HttpHeaders

                    org.jboss.resteasy.core.ContextParameterInjector$GenericDelegatingProxy.invoke(ContextParameterInjector.java:53)

                    com.sun.proxy.$Proxy207.getRequestHeaders(Unknown Source)

                    org.kie.services.remote.rest.ResourceBase.getVariant(ResourceBase.java:115)

                    org.kie.services.remote.rest.exception.DescriptiveExceptionHandler.toResponse(DescriptiveExceptionHandler.java:66)

                    org.kie.services.remote.rest.exception.DescriptiveExceptionHandler.toResponse(DescriptiveExceptionHandler.java:25)

                    sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)

                    sun.reflect.NativeMethodAccessorImpl.invoke(NativeMethodAccessorImpl.java:39)

                    sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:25)

                    java.lang.reflect.Method.invoke(Method.java:597)

                    org.jboss.weld.bean.proxy.AbstractBeanInstance.invoke(AbstractBeanInstance.java:44)

                    org.jboss.weld.bean.proxy.ProxyMethodHandler.invoke(ProxyMethodHandler.java:105)

                    org.kie.services.remote.rest.exception.DescriptiveExceptionHandler$Proxy$_$$_WeldClientProxy.toResponse(DescriptiveExceptionHandler$Proxy$_$$_WeldClientProxy.java)

                    org.jboss.resteasy.core.SynchronousDispatcher.executeExceptionMapper(SynchronousDispatcher.java:324)

                    org.jboss.resteasy.core.SynchronousDispatcher.handleException(SynchronousDispatcher.java:229)

                    org.jboss.resteasy.core.SynchronousDispatcher.invoke(SynchronousDispatcher.java:123)

                    org.jboss.resteasy.plugins.server.servlet.ServletContainerDispatcher.service(ServletContainerDispatcher.java:208)

                    org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:55)

                    org.jboss.resteasy.plugins.server.servlet.HttpServletDispatcher.service(HttpServletDispatcher.java:50)

                    javax.servlet.http.HttpServlet.service(HttpServlet.java:847)

                    org.jboss.weld.servlet.ConversationPropagationFilter.doFilter(ConversationPropagationFilter.java:62)

                    org.jboss.solder.servlet.exception.CatchExceptionFilter.doFilter(CatchExceptionFilter.java:65)

                    org.jboss.solder.servlet.event.ServletEventBridgeFilter.doFilter(ServletEventBridgeFilter.java:74)

                    org.jbpm.designer.web.filter.impl.PluggableFilter.doFilter(PluggableFilter.java:70)

                    org.uberfire.security.server.UberFireSecurityFilter.doFilter(UberFireSecurityFilter.java:266)

                  </pre>

                              </p>

                              <p>

                                  <b>note</b>

                                  <u>The full stack trace of the root cause is available in the JBoss Web/7.0.13.Final logs.</u>

                              </p>

                              <HR size="1" noshade="noshade">

                                  <h3>JBoss Web/7.0.13.Final</h3>

                              </body>

                          </html>

                  • 6. Re: REST API
                    faraon79

                    Solved. The issue was wrong http header, should be:

                     

                    Accept: application/json


                    Now another thing is how to do post request with process definition? Is it still good place for the question or I should start new topic?


                    Maybe I should explain what is the goal. I'd like to use jBPM and its rest api to the following senario:

                    1. Create organizationalUnit, repository, project

                    2. Upload resources (bpmn file)

                    3. Deploy

                    4. Start process instances

                    5. Interact with tasks (claim, start, complete, etc)

                     

                    I found in User Guide almost everything except how to upload resources (as a file or xlm body, whatever). Is is possible at all?

                    • 7. Re: REST API
                      swiderski.maciej

                      assets (like processes, rules, etc) are stored in git repository and you should add/update/remove assets over git and not REST api.

                       

                      Actually I would recommend to split the case into:

                      • design time where you create org units, repositories, projects and assets - model your processes, rules,
                      • build time where you produce artifacts and deploy them to runtime environment
                      • runtime where you actually deploy, execute and manage your live instances of processes and tasks

                      that way you can have rather scalable environment where most likely runtime will require more processing power than the design. Design can be both in kie-wb or in IDE and then uploaded over git into kie-wb for build and deployment.

                       

                      HTH

                      1 of 1 people found this helpful
                      • 8. Re: REST API
                        faraon79

                        Post above really helps me, thanks. Now I can add resources over git when path contains localhost, e.g.

                        git://localhost/repo_name

                        or

                        git://127.0.0.1/repo_name

                         

                        When use localhost address e.g. 192.168.1.1 I get response "Connection refused". Is it possible to change configuration for git server to listen on network addres?

                        • 9. Re: REST API
                          swiderski.maciej

                          take a look here for a list of system properties that allow you to control the git daemon (like host port, etc).

                           

                          HTH

                          • 10. Re: REST API
                            dknoll

                            I'm facing a similar problem ...
                            GET http://<server>/jbpm-console/rest/deployment

                            works correctly, giving a list of deployments, and so does:

                            GET http://<server>/jbpm-console/rest/deployment/org.jbpm:Evaluation:1.0/

                            giving a concrete entity of a deployment.

                             

                            BUT
                            GET http://<server>/jbpm-console/rest/deployment/org.jbpm:Evaluation:1.0/content

                            does not work as suggested by the unofficial documentation

                            Rest Deployment API · mrietveld/droolsjbpm-integration Wiki · GitHub

                             

                            Any suggestions?

                            • 11. Re: REST API
                              faraon79

                              Thx Maciej. Does it require any further server configuration? I tried all of the following property values:

                               

                              <property name="org.uberfire.nio.git.daemon.host" value="192.168.1.1" boot-time="false"/>

                              <property name="org.uberfire.nio.git.daemon.host" value="192.168.1.1" boot-time="true"/>

                              <property name="org.uberfire.nio.git.daemon.host" value="192.168.1.1" />

                              <property name="org.uberfire.nio.git.daemon.host" value="0.0.0.0" boot-time="false"/>

                              <property name="org.uberfire.nio.git.daemon.host" value="0.0.0.0" boot-time="true"/>

                              <property name="org.uberfire.nio.git.daemon.host" value="0.0.0.0" />


                              EDIT:

                              Form user guide:

                              1. Edit the file $JBOSS_HOME/domain/configuration/host.xml.
                              2. Locate the XML elements server that belong to the main-server-group and add a system property, for example:


                              Solution:

                              In the Standalone mode,  the change will go into standalone.xml

                              Add the system-properties  element right after the extensions element.


                              You have to remove "boot-time" property at all, otherwise EAP fails.


                              EDIT2:


                              Why such configuration works fine on BRMS6 beta and fails on BRMS6 GA (push not permitted)?

                              • 12. Re: REST API
                                swiderski.maciej

                                for GA push was restricted to ssh connections only that requires authentication. So you need to use ssh://host:port/repository instead of git as protocol. Default values are:

                                ssh://localhost:8001/repository alternatively you can provide username instead of using one that you're logged on to OS: ssh://user@localhost:8001/repository

                                 

                                user that is used fo ssh connection must be valid user known to brms.

                                 

                                HTH

                                • 13. Re: REST API
                                  faraon79

                                  Is it posssible to delete Project in jBPM6 using REST API? User guide doesn't mention it but BPM SUITE user guide does.

                                  • 14. Re: REST API
                                    swiderski.maciej

                                    if it's documented for BPM suite then it's available in jBPM6 as well.

                                     

                                    HTH