I’m trying to use Groovy’s RESTClient to connect to Graylog server and use it’s REST API. I want a JSON response from Graylog.
This is my RESTClient (Graylog is running on my local machine)
def restClient = new RESTClient("http://localhost:9000/api/") restClient.auth.basic 'admin', 'admin' def response = restClient.get( path:"search/universal/relative?query=hello&range=50000&fields=message&decorate=true", headers:[ "Accept": "application/json" ] )
It’s a simple rest client trying to search for a word “hello” in Graylog’s messages. I keep getting 404 Not Found exception
If I use the following curl command, I do get my JSON response.
curl --user admin:admin -H ‘Accept: application/json’ -X GET “http://localhost:9000/api/search/universal/relative?query=hello&range=50000&fields=message”
I tried the same REST API call using Postman and am able to get a JSON response back.
What did I miss in my groovy rest client that is causing it to receive a HttpResponseException?
I noticed that If I change the “path” parameter to “streams”, everything works just fine. But, I can’t seem to call the search API successfully.
Graylog version is 2.2.3-1