Hi,
using graylog latest 4.1 I’m trying to get the admin token. Using swagger API view I found the follow api
but when I test Processing: graylog-rest-error.txt…
it I have an error:
And this is the exception when I try it using curl
curl -i -u admin:admin -H 'Accept: application/json' -X GET 'http://[GRAYLOG_HOST]:[GRAYLOG_PORT]/api/users/admin/tokens/?pretty=true'
HTTP/1.1 500 Internal Server Error
X-Graylog-Node-ID: 116abfd3-f25a-4b4e-b1cb-35fbf63a995d
Content-Type: application/json
Connection: close
Content-Length: 101
{
"type" : "ApiError",
"message" : "invalid hexadecimal representation of an ObjectId: [admin]"
}
-------------------------------
2021-10-29 15:44:08,230 ERROR: org.graylog2.shared.rest.exceptionmappers.AnyExceptionClassMapper - Unhandled exception in REST resource
java.lang.IllegalArgumentException: invalid hexadecimal representation of an ObjectId: [admin]
at org.bson.types.ObjectId.parseHexString(ObjectId.java:529) ~[graylog.jar:?]
at org.bson.types.ObjectId.<init>(ObjectId.java:205) ~[graylog.jar:?]
at org.graylog2.database.PersistedServiceImpl.get(PersistedServiceImpl.java:60) ~[graylog.jar:?]
at org.graylog2.users.UserServiceImpl.loadById(UserServiceImpl.java:117) ~[graylog.jar:?]
at org.graylog2.rest.resources.users.UsersResource.loadUserById(UsersResource.java:667) ~[graylog.jar:?]
at org.graylog2.rest.resources.users.UsersResource.listTokens(UsersResource.java:606) ~[graylog.jar:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke0(Native Method) ~[?:?]
at jdk.internal.reflect.NativeMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at jdk.internal.reflect.DelegatingMethodAccessorImpl.invoke(Unknown Source) ~[?:?]
at java.lang.reflect.Method.invoke(Unknown Source) ~[?:?]
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$TypeOutInvoker.doDispatch(JavaResourceMethodDispatcherProvider.java:219) ~[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:255) [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:234) [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(Unknown Source) [?:?]
at java.util.concurrent.ThreadPoolExecutor$Worker.run(Unknown Source) [?:?]
at java.lang.Thread.run(Unknown Source) [?:?]
So using API I’m not able to get and create admin token
Can anyone help me figure out where I’m wrong?