Reaper HTTP REST API Curl Examples

475 views
Skip to first unread message

Rhys Campbell

unread,
Oct 23, 2019, 4:56:26 AM10/23/19
to TLP Apache Cassandra Reaper users
Hello All,

Does anyone have any examples using curl with the Reaper http rest api? I want to create a few basic Nagios checks using the API.

I receive a pong on the http://localhost:8081/ping url but I get 404 on all other requests. I do have shiro auth enabled but get a 404 on the /login url as well. FYI - the spreaper tool doesn't work out of the box with a rpm install. 

Cheers,

Rhys

Alexander Dejanovski

unread,
Oct 23, 2019, 6:08:39 AM10/23/19
to Rhys Campbell, TLP Apache Cassandra Reaper users
Hi Rhys, 

I think you need to set the "content-type" header to be "application/json" for most operations.
The login endpoint will need a "application/x-www-form-urlencoded" content type and you'll need to pass username, password and rememberMe as form parameters in the body.
Not sure how this is done specifically with curl though.

Here's how I set it up with ARC, which is a Chrome extension to send REST requests :
Capture d’écran 2019-10-23 à 12.03.36.png
You may also check the spreaper code to see how we interact with the REST endpoints from Python.
Note that you don't need a jwt as long as you pass the JSESSIONID cookie in all your requests. 

Cheers,

-----------------
Alexander Dejanovski
France
@alexanderdeja

Consultant
Apache Cassandra Consulting


--
You received this message because you are subscribed to the Google Groups "TLP Apache Cassandra Reaper users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to tlp-apache-cassandra-r...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/tlp-apache-cassandra-reaper-users/45df20be-da60-4069-9b62-2b49b19ac6d4%40googlegroups.com.

Rhys Campbell

unread,
Oct 23, 2019, 10:00:54 AM10/23/19
to Alexander Dejanovski, TLP Apache Cassandra Reaper users
Thanks got it. For the benefit of others...

Login with...


curl -v -X POST -H "Content-Type: application/x-www-form-urlencoded" -d @data.txt  http://localhost:8080/login

-v - Display the headers. You will need the Set-Cookie value for further requests.
-d - Text file with username & password params. In form username=username&password=secret

Then you can make requests as follows...

# List clusters in reaper...
curl --cookie "JSESSIONID=XXXXXXXXXXXXXXXXXXXXXXX;Path=/" http://localhost:8080/cluster


Alexander Dejanovski

unread,
Oct 23, 2019, 10:05:20 AM10/23/19
to Rhys Campbell, TLP Apache Cassandra Reaper users
Thanks for sharing!

-----------------
Alexander Dejanovski
France
@alexanderdeja

Consultant
Apache Cassandra Consulting

Reply all
Reply to author
Forward
0 new messages