Question

Any examples for accessing Guvnor server using cURL?

Try 1:

 curl -i --user username:pwd -H"Content-Type: application/json" -X GET localhost:8080/guvnor-server/rest/packages

Returns:

 HTTP/1.1 401 Unauthorized

Try 2:

curl -X GET -u"username:pwd" localhost:8080/guvnor-server/rest/packages.json

Returns:

 HTTP/1.1 404 Not Found

Referring: docs.jboss.org/drools/release/5.5.0.CR1/drools-guvnor-docs/html/ch09 dot html

Thx!

Was it helpful?

Solution

This worked for me on Guvnor 5.5.0.Final under Tomcat 7

Using:

curl -v -u {user}:{password} -H "Accept: application/json" curl-X GET localhost:8080/drools-guvnor/rest/packages

Returns:

* About to connect() to localhost port 8080 (#0)
*   Trying ::1... connected
* Server auth using Basic with user '{user}'
> GET /drools-guvnor/rest/packages HTTP/1.1
> Authorization: Basic ZGF2aWQ6ZGF2aWQ=
> User-Agent: curl/7.22.0 (i686-pc-linux-gnu) libcurl/7.22.0 OpenSSL/1.0.1 zlib/1.2.3.4 libidn/1.23 librtmp/2.3
> Host: localhost:8080
> Accept: */*
>
< HTTP/1.1 200 OK
< Server: Apache-Coyote/1.1
< Set-Cookie: JSESSIONID=68225AF4B272E5CCA962FFE83BCB008A; Path=/drools-guvnor/; HttpOnly
< Content-Type: application/json
< Transfer-Encoding: chunked
< Date: Sat, 18 May 2013 17:10:51 GMT
<
* Connection #0 to host localhost left intact
* Closing connection #0
[{"package":{"assets":"http:\/\/localhost:8080\/drools-guvnor\/rest\/packages\/defaultPackage\/assets\/drools","author":"{user}","binar                                  yLink":"http:\/\/localhost:8080\/drools-guvnor\/rest\/packages\/defaultPackage\/binary","description":"The default rule package","meta                                  data":{"archived":false,"checkinComment":"Initial","created":"2013-05-18T12:34:53.825-04:00","state":"","uuid":"ab4ae1a2-10d7-43e7-9d8                                  e-411c93a8e669","versionNumber":1},"published":"2013-05-18T12:34:53.833-04:00","sourceLink":"http:\/\/localhost:8080\/drools-guvnor\/r

Troubleshooting:

HTTP Status 500 - Unable to find JAXBContext for media type: application/json

This error occurs because "resteasy no longer includes json support in the jars" according to this post by @sstarcher. What is not clear from that answer, was how to fix the problem in drools-guvnor.

In this case, using drools-guvnor.5.5.0.Final, you need to download two jar files:

- [jettison-1.3.3.jar][2]
- [resteasy-jettison-provider-2.2.3.GA.jar][3]

You should place both jar files in your {TOMCAT_HOME}/webapps/drools-guvnor/WEB-INF/lib folder. which looks like this on some systems:

 /usr/local/tomcat/apache-tomcat-7.0.35/webapps/drools-guvnor/WEB-INF/lib

Next stop and restart the webserver. On Tomcat from the {TOMCAT_HOME}/bin directory you can use the ./shutdown.sh and ./startup.sh commands.

401 - Unauthorized. This occurs if you don't use the -u user:pass optional argument. Out of the box, guvnor uses a fake basic authenticator which requires headers to work.

404 -Not Found. This error will occur if you have not specified the correct name of the directory or resource in the request.

405 - Method Not allowed. Happens when you mangle the curl options, forget quotes, etc.

406 - Not Acceptable. This error will occur if you specified an unsupported 'Accept:' Header using the -H option for curl.

HTH

Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top