Hey Jens,
you are missing the password field in your user creation API call. I could only
determine this by checking the source code. I will add some validation the
server resource, so a proper error message is returned in future version! :)
Kr,
D.
On 05.06.2014, at 16:58, Jens Kuehnel <[email protected]> wrote:
> Hi,
>
> I try to create a couple of new users with POST to /users. The
> API-Browser tells me to use a JSON body, but without the infos what
> should be inside.
>
> I used the output of GET /users/{username} as a starting point.
>
> {
> "id":"539047e2e4b092d07a61c05e",
> "startpage":{},
> "timezone":"Europe/Berlin",
> "username":"XXXXXXXXX",
> "read_only":false,
> "session_timeout_ms":111000,
> "email":"test@localhost",
> "external":false,
> "permissions":[
> "messagecount:read",
> "messages:read",
> "throughput:read",
> "savedsearches:create",
> "savedsearches:read",
> "users:passwordchange:XXXXXXXXX",
> "fieldnames:read",
> "inputs:read",
> "jvmstats:read",
> "metrics:read",
> "buffers:read",
> "savedsearches:edit",
> "streams:read:537f4e19e4b061f0c9047fce",
> "indexercluster:read",
> "users:edit:XXXXXXXXX",
> "system:read"
> ],
> "full_name":"XXXXXXXXX"
> }
>
> and used this command:
>
> cat usertemplate.json | sed -e 's:XXXXXXX:testuser:' -e
> 's:YYYYYYYYYYYYYYYY:testuser:' | curl -v -u USERNAME -X POST -d @-
> --header "Content-Type:application/json"
> http://127.0.0.1:12900/users/ --trace -
>
> The errors from the error log were helpful:
>
> 16:34:39,866 ERROR [RestResource] Error while parsing JSON
> com.fasterxml.jackson.databind.exc.UnrecognizedPropertyException:
> Unrecognized field "id" (class
> org.graylog2.rest.resources.users.requests.CreateRequest), not marked as
> ignorable (8 known properties: "startpage", "permissions", "username",
> "timezone", "fullname", "password", "email", "session_timeout_ms"])
>
> So I removed "id", "read_only" and "external" and tried it again. But
> the new error message looks like this:
>
> 16:37:03,471 ERROR [AnyExceptionClassMapper] Unhandled exception in REST
> resource
> java.lang.NullPointerException
> at org.apache.shiro.crypto.hash.SimpleHash.hash(SimpleHash.java:229)
> at org.apache.shiro.crypto.hash.SimpleHash.<init>(SimpleHash.java:178)
> at org.apache.shiro.crypto.hash.SimpleHash.<init>(SimpleHash.java:139)
> at
> org.graylog2.rest.resources.users.UsersResource.create(UsersResource.java:121)
> at sun.reflect.NativeMethodAccessorImpl.invoke0(Native Method)
>
> I tried it in graylog2 0.20.2 and 0.20.1, same error in both.
>
> Is there a documentation who the JSON should be formated? Has anybody
> used this before and can send me an working example?
>
> Thanks for the help
>
> CU
> Jens
>
> --
> You received this message because you are subscribed to the Google Groups
> "graylog2" group.
> To unsubscribe from this group and stop receiving emails from it, send an
> email to [email protected].
> For more options, visit https://groups.google.com/d/optout.
--
TORCH GmbH
Steckelhörn 11
20457 Hamburg
Tel +49 (0)40-60945200
https://www.torch.sh
Commercial Reg. (Registergericht): Amtsgericht Hamburg, HRB 125175
Geschäftsführer: Hass Chapman, Lennart Koopmann
--
You received this message because you are subscribed to the Google Groups
"graylog2" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
For more options, visit https://groups.google.com/d/optout.