Running Commands with REST and Json

1,134 views
Skip to first unread message

ianEve

unread,
Jun 27, 2016, 8:59:59 AM6/27/16
to Drools Usage
Hi Community,

I just installed Kie Workbench and Kie Execeution Server (Version 6.4) on Wildfly 8.x. Now I'd like to try the "Fire-Alert" example taken from Chapter 6 of the documentation. So I put the facts consisting of Room, Sprinkler, Alert and Fire to a jar file and deployed it with Kie Workbench. I also added my DRL-file, validated it and deployed it. So far, everything works fine.

Now I want to run the example with REST by executing a batch command in JSON format. The problem I have is getting the error: "Bad request, no commands to be executed - either wrong format or no data".

The attached picture visuals the REST-Call (executed by Postman).

This is the whole rest command:
POST /kie-server/services/rest/server/containers/instances/BreezePrototype HTTP/1.1
Host: localhost:8080
X
-KIE-ContentType: json
Authorization: Basic a2llc2VydmVyOmtpZXNlcnZlcjEh
Accept: application/json
Content-Type: application/json
Cache-Control: no-cache
Postman-Token: 8535c021-519a-57d4-109f-66360efc03cb

{"batch-execution":{"commands":[{"insert":{"out-identifier":"Kitchen_room","return-object":true,"entry-point":"DEFAULT","object":{"de.myPackage.facts.Room":{"name":"kitchen"}}}},{"insert":{"out-identifier":"Kitchen_fire","return-object":true,"entry-point":"DEFAULT","object":{"de.myPackage.facts.Fire":{"room":{"name":"kitchen"}}}}},{"insert":{"out-identifier":"Kitchen_sprinkler","return-object":true,"entry-point":"DEFAULT","object":{"de.myPackage.facts.Sprinkler":{"room":{"name":"kitchen"},"on":true}}}},{"fire-all-rules":""}]}}

Has anybody of you any idea how to solve the problem?

Regards, ian
kie_rest_json.png

Maciej Swiderski

unread,
Jun 27, 2016, 10:57:37 AM6/27/16
to drools...@googlegroups.com
you use wrong payload, simply remove the batch-execution layer from your json so it starts {“commands”….

Maciej
--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage...@googlegroups.com.
To post to this group, send email to drools...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/drools-usage/aa565552-f9c2-47a7-bf4f-2180cbf0bad6%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.
<kie_rest_json.png>

ianEve

unread,
Jun 28, 2016, 2:38:20 AM6/28/16
to Drools Usage
Thanks for your answer. But now I am getting another error with message: Error calling container BreezePrototype: Error unmarshalling input

Do you have any solution for that message?

regards, ian

ianEve

unread,
Jun 28, 2016, 3:21:13 AM6/28/16
to Drools Usage
OK - I got it.... The default constructor was missing in the facts, so it didn't work

Cheers! ian

vijay yadav

unread,
Jul 12, 2017, 7:29:28 AM7/12/17
to Drools Usage
hey
would you please elaborate how did you solve this issue?

Thanks

ASHISH NATHANI

unread,
Jul 26, 2017, 2:21:09 AM7/26/17
to Drools Usage, anish.s...@hotmail.com
Hi Michalski,

I have set up kie server and workbench on my system and I am able to fire the rules through rest calls now . But I am facing two major issue and these are  when I update the rule I need to create a new container with new version for that rule and secondly when I create the new container  it is not instantiated and for that I need to restart my server .
Is there any way through which I can update and deploy new / modified rules at run time

Thanks in advance

Regards
Ashish Nathani


On Monday, June 27, 2016 at 6:29:59 PM UTC+5:30, J. Michalski wrote:

ASHISH NATHANI

unread,
Jul 26, 2017, 2:22:55 AM7/26/17
to Drools Usage
Hi Maciej,

Abhijit Humbe

unread,
Jul 26, 2017, 3:14:10 AM7/26/17
to drools...@googlegroups.com
To upgrade rules at runtime you can use KieScanner functionality supported by kie-server. Keep the version of jar(project) same and specify scan interval. Kie-server will keep checking maven repository if updated jar/project is available or not.  When you create new container what exception you encounter while starting container ?

Abhijit Humbe

--
You received this message because you are subscribed to the Google Groups "Drools Usage" group.
To unsubscribe from this group and stop receiving emails from it, send an email to drools-usage+unsubscribe@googlegroups.com.

To post to this group, send email to drools...@googlegroups.com.

ASHISH NATHANI

unread,
Jul 26, 2017, 3:42:10 AM7/26/17
to Drools Usage
Hi Abhijit,

Thanks for the response.

1) Firstly, I can see that the scanner button is disabled in my workbench's execution server tab. Im not sure how will it get enabled.
2) Secondly when I try to start the scanner using rest call it gives me status 200 ok but in the list of scanned items for a container it doest show up.

Moreover, when I try to hit build and deploy option it always asks for a new version as it says that container is already in use. Also when we create a new container (check box is marked for Start Container), the container starts up(as seen in the execution server tab) but the endpoint says that container is not instantiated.

So I am a bit confused as to why I always need to restart the server to instantiate the new containers.

Task in hand - Is to modify or add new rules and deploy them with the same version so that the rest endpoint doesn't change and new rules start executing.

FYI- Using kieserver(7.1.0Final) kie workbench(7.0.0 Final) on wildfly 10.

Thanks in advance.

Regards,
Ashish

Reply all
Reply to author
Forward
0 new messages