10 Replies Latest reply on Mar 14, 2013 1:26 PM by Rocky Triton

    Create Guvnor Asset Using Rest API

    dme Newbie



      Is there an example of how to create an Asset in Guvnor using the Rest API? I have tried to use the following code:

      static String widxml = "<?xml version=\"1.0\" encoding=\"UTF-8\" standalone=\"yes\"?><asset><checkInComment>Test</checkInComment><description>This is a Work Item Definition Configuration File</description><metadata><format>wid</format><title>Sample3</title></metadata><type></type><version>1</version></asset>";


          WebClient client = WebClient.create("");
          String content = client.path("drools-guvnor/rest/packages/demo/assets/Sample2").accept("application/xml").get(String.class);


          System.out.println("content = " + content);


          String authorizationHeader = "Basic " + org.apache.cxf.common.util.Base64Utility.encode("guest:".getBytes());
          WebClient client2 = WebClient.create("");
          client2.header("Authorization", authorizationHeader);
          Response response= client2.path("drools-guvnor/rest/packages/demo/assets").accept("application/atom+xml").post(widxml);
          System.out.println("response = " + response.getStatus());


        This throws a HTTP 415 exception.


      If I change the type to "application/xml" I get a 406 error.


      Can someone tell me whats wrong with my code, and if there is a sample which shows how I can add an asset using the REST API.