Bug 1314565

Summary: Unable to execute rules via Rest API
Product: [Retired] JBoss BRMS Platform 6 Reporter: Sudheer <schekka>
Component: Kie-ServerAssignee: Edson Tirelli <etirelli>
Status: CLOSED EOL QA Contact: Karel Suta <ksuta>
Severity: unspecified Docs Contact:
Priority: medium    
Version: 6.2.0CC: eschabel
Target Milestone: ER3   
Target Release: 6.3.0   
Hardware: Unspecified   
OS: Unspecified   
Whiteboard:
Fixed In Version: Doc Type: Bug Fix
Doc Text:
Story Points: ---
Clone Of: Environment:
Last Closed: 2020-03-27 19:08:53 UTC Type: Bug
Regression: --- Mount Type: ---
Documentation: --- CRM:
Verified Versions: Category: ---
oVirt Team: --- RHEL 7.3 requirements from Atomic Host:
Cloudforms Team: --- Target Upstream Version:

Description Sudheer 2016-03-03 23:00:49 UTC
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 17:31:54 UTC
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 22:05:11 UTC
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 15:49:28 UTC
(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 05:02:11 UTC
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 12:21:11 UTC
(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 15:41:49 UTC
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-07 01:50:02 UTC
Thank you guys. Yes, the X-KIE-ContentType header is mandatory for content type application/xml.