-
1. Re: Create Guvnor Asset Using Rest API
skitch Mar 30, 2012 3:29 PM (in response to dme)Hey dme,
The problem seems to be that the Guvnor API only accepts application/atom+xml for the "Create Asset" Restful POST call. Problematic on my end since I'd prefer to use JSON. This is kind of discouraging as well, since all other REST calls accept JSON/XML/Atom.
-
2. Re: Create Guvnor Asset Using Rest API
dme Apr 2, 2012 10:29 AM (in response to skitch)The Atom/XML worked for me. I was missing the SLUG header, once I added that, I could create the WID thru the REST interface.
-
3. Re: Create Guvnor Asset Using Rest API
leosoubeste Nov 6, 2012 2:38 PM (in response to dme)Could you explain how to add the Slug header? How did you modify your code in this example?
Thanks
-
4. Re: Create Guvnor Asset Using Rest API
dme Nov 6, 2012 2:59 PM (in response to leosoubeste)https://community.jboss.org/message/724446. This post has some information on how to add the Slug header. The other post uses HttpConnection, you can convert to CXF if thats what you are using.
-
5. Re: Create Guvnor Asset Using Rest API
rockypulley Nov 6, 2012 5:00 PM (in response to dme)I am able to create an asset, but I cannot link to a global asset. For instance I want to link to a global model with the REST API, how would I go about doing that?
-
6. Re: Create Guvnor Asset Using Rest API
leosoubeste Nov 9, 2012 12:52 PM (in response to rockypulley)That was helpful, thanks! This is how I did it in case someone else wonders.
WebClient client = WebClient.create("http://" + guvnorHost + ":" + guvnorPort);
MultivaluedMap<String, String> map = new MetadataMap<String, String>();
List<String> slugHeader = new ArrayList<String>();
slugHeader.add(assetName);
List<String> authHeader = new ArrayList<String>();
authHeader.add(authorizationHeader);
List<String> contentTypeHeader = new ArrayList<String>();
contentTypeHeader.add("application/octet-stream");
map.put("Slug", slugHeader);
map.put("Authorization", authHeader);
map.put("Content-Type", contentTypeHeader);
client.headers(map);
Response response = client.path("drools-guvnor/rest/packages/" + packageName + "/assets").accept("application/atom+xml").post(asset);
-
7. Re: Create Guvnor Asset Using Rest API
richard916 Nov 21, 2012 8:31 AM (in response to dme)does anyone know how to create an POJO model asset with REST API?
I post
"
<entry xml:base="http://localhost:9080/repository/packages/package1/assets">
<title>testAsset1</title>
<summary>desc1</summary>
</entry>
" but the format is by default "txt"...
-
8. Re: Create Guvnor Asset Using Rest API
ravinandan Dec 23, 2012 1:03 PM (in response to richard916)I too am interested in solution to this problem.
Has anyone found workaround for this?
-
9. Re: Create Guvnor Asset Using Rest API
magick93 Mar 14, 2013 11:16 AM (in response to rockypulley)I want to link to a global model with the REST API, how would I go about doing that?
Im also looking to do the same. Did anyone find a solution to creating a new rule that uses a pojo in the global package?
-
10. Re: Create Guvnor Asset Using Rest API
rockytriton Mar 14, 2013 1:26 PM (in response to magick93)Sorry, it can't be done with the REST API. I had to use java code to do it and I wrapped it in my own REST API. I would post the code but I'm no longer working on that project and don't have access to it anymore.