Bug 1314565 - Unable to execute rules via Rest API
Unable to execute rules via Rest API
Status: VERIFIED
Product: JBoss BRMS Platform 6
Classification: JBoss
Component: Kie-Server (Show other bugs)
6.2.0
Unspecified Unspecified
medium Severity unspecified
: ER3
: 6.3.0
Assigned To: Edson Tirelli
Karel Suta
:
Depends On:
Blocks:
  Show dependency treegraph
 
Reported: 2016-03-03 18:00 EST by Sudheer
Modified: 2016-04-15 10:33 EDT (History)
1 user (show)

See Also:
Fixed In Version:
Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of:
Environment:
Last Closed:
Type: Bug
Regression: ---
Mount Type: ---
Documentation: ---
CRM:
Verified Versions:
Category: ---
oVirt Team: ---
RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: ---


Attachments (Terms of Use)

  None (edit)
Description Sudheer 2016-03-03 18:00:49 EST
Description of problem: Throwing an error when calling Rest API to execute rules

Version-Release number of selected component (if applicable): JBoss BRMS 6.2


How reproducible:


Steps to Reproduce:
1. Follow steps in https://github.com/jbossdemocentral/brms-loan-realtime-decision-server-demo
2. Fails at Step 18
3.

Actual results:
JBWEB000125: The specified HTTP method is not allowed for the requested resource.

Expected results:
Results from Rules execution 


Additional info:
Comment 2 Edson Tirelli 2016-03-04 12:31:54 EST
Due to limitations in some of the JEE containers, we had to change the POST URI for version 6.2. The linked example is outdated.

The correct URI for the POST in step 18 is:

http://localhost:8080/kie-server/services/rest/server/containers/instances/container-loan1.0

Instead of:

http://localhost:8080/kie-server/services/rest/server/containers/container-loan1.0

Documentation also needs to be updated.

Eric, can I ask you please to do a quick update on the example? I will update the kie docs.
Comment 3 Sudheer 2016-03-04 17:05:11 EST
I was just told that X-KIE-ContentType HTTP header [1] needs to be set as well for the rest calls to work. Can this be incorporated into the documentation too if it is required.

[1] https://access.redhat.com/solutions/2129781
Comment 4 Eric D. Schabell 2016-03-05 10:49:28 EST
(In reply to Edson Tirelli from comment #2)
> Due to limitations in some of the JEE containers, we had to change the POST
> URI for version 6.2. The linked example is outdated.
> 
> The correct URI for the POST in step 18 is:
> 
> http://localhost:8080/kie-server/services/rest/server/containers/instances/
> container-loan1.0
> 
> Instead of:
> 
> http://localhost:8080/kie-server/services/rest/server/containers/container-
> loan1.0
> 
> Documentation also needs to be updated.
> 
> Eric, can I ask you please to do a quick update on the example? I will
> update the kie docs.
>
that fix is already in the project... Readme shows this new url already?
Comment 5 Sudheer 2016-03-18 01:02:11 EDT
Eric, ReadMe still shows POST url in Step 18 without the context "instances".

Edson, I tried with the new url you mentioned on 6.2 and I am getting empty response back following the steps in the same example:

<response type="SUCCESS" msg="Container DevServer successfully called.">
<results>
<?xml version="1.0" encoding="UTF-8" standalone="yes"?> <execution-results> <results> <item key="applicant"/> <item key="loan"/> </results> <facts> <item key="applicant"/> <item key="loan"/> </facts> </execution-results>
</results>
</response>

I am using this input:
<batch-execution>
	 <insert out-identifier="applicant">
		 <com.redhat.loandemo.Applicant>
		 	<name>Eric D. Schabell</name>
			 <creditScore>530</creditScore>
		 </com.redhat.loandemo.Applicant>
	 </insert>
	<insert out-identifier="loan">
		<com.redhat.loandemo.Loan>
			 <amount>4500</amount>
			 <duration>24</duration>
			 <interestRate>1.5</interestRate>
		</com.redhat.loandemo.Loan>
	</insert>
	<fire-all-rules />
</batch-execution>


However for the same rules server on BRMS 6.1, it just works fine with this response:
<response type="SUCCESS" msg="Container container-loan1.0 successfully called.">
<results>
<execution-results> <result identifier="applicant"> <com.redhat.loandemo.Applicant> <name>Eric D. Schabell</name> <creditScore>530</creditScore> </com.redhat.loandemo.Applicant> </result> <result identifier="loan"> <com.redhat.loandemo.Loan> <amount>4500</amount> <duration>24</duration> <interestRate>1.5</interestRate> <approved>true</approved> </com.redhat.loandemo.Loan> </result> <fact-handle identifier="applicant" external-form="0:1:1061539597:1061539597:1:DEFAULT:NON_TRAIT"/> <fact-handle identifier="loan" external-form="0:2:475324772:475324772:2:DEFAULT:NON_TRAIT"/> </execution-results>
</results>
</response>
Comment 6 Eric D. Schabell 2016-03-18 08:21:11 EDT
(In reply to Sudheer from comment #5)
> Eric, ReadMe still shows POST url in Step 18 without the context "instances".
> 
Fixed for sure now in master and part of v1.2 tag of the demo project.
Comment 7 Sudheer 2016-03-18 11:41:49 EDT
Cool, I see the updated Post URL now. Thanks Eric.

I also had to use customer header "X-KIE-ContentType: xstream" to get it working for BRMS 6.2. @Eric, I sent you a PR for your git example.

This issue can be closed now.
Comment 8 Edson Tirelli 2016-04-06 21:50:02 EDT
Thank you guys. Yes, the X-KIE-ContentType header is mandatory for content type application/xml.

Note You need to log in before you can comment on or make changes to this bug.