Powershell REST API Search - ApiError message:""

Hello Graylog Community,

I try to grep RAW Logs via Powershell and REST API with following json and Invoke-RestMethod:

$json1 = '{

            "queries": [{

                "id":"?",

                "timerange": {

                    "type": "relative",

                    "range": 3600

                },

                "query":

                {

                    "query_string":"source:examplesource",

                    "type": "elasticsearch"

                },

                "search_types": [{

                    "timerange": null,

                    "query": null,

                    "streams": ["609c3daa4d3cfc167e090c92"],

                    "id": "?",

                    "name": null,

                    "limit": 150,

                    "offset": 0,

                    "sort": [{

                        "field": "timestamp",

                        "order": "ASC"

                    }],

                    "decorators": [],

                    "type": "messages",

                    "filter": null

                }]

            }]

}' 

$Result = Invoke-RestMethod -Method Post -Body $json1 -ContentType "application/json" -Headers $Headers -Uri ${proto}://$hostname/api/views/search -Verbose -Credential $PSCredential

I just get the following as error: Invoke-RestMethod : {“type”:“ApiError”,“message”:""}

At the System Logs:
ERROR: org.graylog2.shared.rest.exceptionmappers.AnyExceptionClassMapper - Unhandled exception in REST resource

java.lang.IllegalArgumentException: null


	at org.bson.types.ObjectId.isValid(ObjectId.java:86) ~[graylog.jar:?]


	at org.bson.types.ObjectId.parseHexString(ObjectId.java:528) ~[graylog.jar:?]


	at org.bson.types.ObjectId.<init>(ObjectId.java:205) ~[graylog.jar:?]


	at org.graylog.plugins.views.search.db.SearchDbService.get(SearchDbService.java:65) ~[graylog.jar:?]


	at org.graylog.plugins.views.search.rest.SearchResource.createSearch(SearchResource.java:130) ~[graylog.jar:?]


	at sun.reflect.GeneratedMethodAccessor507.invoke(Unknown Source) ~[?:?]


	at sun.reflect.DelegatingMethodAccessorImpl.invoke(DelegatingMethodAccessorImpl.java:43) ~[?:1.8.0_292]


	at java.lang.reflect.Method.invoke(Method.java:498) ~[?:1.8.0_292]


	at org.glassfish.jersey.server.model.internal.ResourceMethodInvocationHandlerFactory.lambda$static$0(ResourceMethodInvocationHandlerFactory.java:52) ~[graylog.jar:?]


	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher$1.run(AbstractJavaResourceMethodDispatcher.java:124) ~[graylog.jar:?]


	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.invoke(AbstractJavaResourceMethodDispatcher.java:167) ~[graylog.jar:?]


	at org.glassfish.jersey.server.model.internal.JavaResourceMethodDispatcherProvider$ResponseOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:176) ~[graylog.jar:?]


	at org.glassfish.jersey.server.model.internal.AbstractJavaResourceMethodDispatcher.dispatch(AbstractJavaResourceMethodDispatcher.java:79) ~[graylog.jar:?]


	at org.glassfish.jersey.server.model.ResourceMethodInvoker.invoke(ResourceMethodInvoker.java:469) ~[graylog.jar:?]


	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:391) ~[graylog.jar:?]


	at org.glassfish.jersey.server.model.ResourceMethodInvoker.apply(ResourceMethodInvoker.java:80) ~[graylog.jar:?]


	at org.glassfish.jersey.server.ServerRuntime$1.run(ServerRuntime.java:253) [graylog.jar:?]


	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:248) [graylog.jar:?]


	at org.glassfish.jersey.internal.Errors$1.call(Errors.java:244) [graylog.jar:?]


	at org.glassfish.jersey.internal.Errors.process(Errors.java:292) [graylog.jar:?]


	at org.glassfish.jersey.internal.Errors.process(Errors.java:274) [graylog.jar:?]


	at org.glassfish.jersey.internal.Errors.process(Errors.java:244) [graylog.jar:?]


	at org.glassfish.jersey.process.internal.RequestScope.runInScope(RequestScope.java:265) [graylog.jar:?]


	at org.glassfish.jersey.server.ServerRuntime.process(ServerRuntime.java:232) [graylog.jar:?]


	at org.glassfish.jersey.server.ApplicationHandler.handle(ApplicationHandler.java:680) [graylog.jar:?]


	at org.glassfish.jersey.grizzly2.httpserver.GrizzlyHttpContainer.service(GrizzlyHttpContainer.java:356) [graylog.jar:?]


	at org.glassfish.grizzly.http.server.HttpHandler$1.run(HttpHandler.java:200) [graylog.jar:?]


	at com.codahale.metrics.InstrumentedExecutorService$InstrumentedRunnable.run(InstrumentedExecutorService.java:180) [graylog.jar:?]


	at java.util.concurrent.ThreadPoolExecutor.runWorker(ThreadPoolExecutor.java:1149) [?:1.8.0_292]


	at java.util.concurrent.ThreadPoolExecutor$Worker.run(ThreadPoolExecutor.java:624) [?:1.8.0_292]


	at java.lang.Thread.run(Thread.java:748) [?:1.8.0_292]

How can I fix this? I realy dont know how to troubleshoot my issue without an error message or an useful api documentation.

Finally I want to get RAW Logs of my Audiocodes Devices for importing in Syslog Viewer and CSV Export is no option for this use case.

Thanks in advance.

moJO

We are using Graylog Version 4.0.7. Sorry forgot that in my first post.

Hi @moJ090,
there is a Rest API browser, where you can try and show docs for API calls.
https://docs.graylog.org/en/4.0/pages/configuration/rest_api.html?highlight=rest#using-the-api-browser

Also another great tool is development tools for browsers, Network tab, check for all API call while browse desired page a check for api call. Graylog web UI uses API call for all functions, so you should find desired one.

This topic was automatically closed 14 days after the last reply. New replies are no longer allowed.