Search code examples
drools

Drools Setup › Endpoint doesn't respond JSON requests


With the KIE Workbench I created successfully a container in the Rule Deployments. I made a drools project in kie and using the endpoint, it responds perfectly the xml (xstream) drools commands. For what I read I understood that the RESTful webservice also should supports JSON. I tried to do the same calls now with JSON (using RESTClient), but it doesn't work.

Caused by: org.xmlpull.v1.XmlPullParserException: only whitespace content allowed before start tag and not { (position: START_DOCUMENT seen {... @1:1)

Although I indicate "application/json" as mediatype it seems the webservice is trying to read it as xml.

In the wadl it seems that "application/xml" is the only valid request mediatype.

Do I need to do some additional configuration to make it work with JSON?

Best regards,

Kishor


Solution

  • KIE Server requires two headers for JSON:

    X-KIE-ContentType: JSON
    Content-Type: application/json
    

    The error message indicates your request does not contain the first one above.