"problem: Null fullName" occurs while sending a POST Add User request

Hi All,

Graylog version : 2.3.2+3df951e, codename Tegernseer

I am trying to automate our user provisioning/deprovisioning workflow by creating a tool that sends Rest calls to graylog. To create a user I am sending a POST rest call using the following code snippet :

CreateUserRequest request = CreateUserRequest.create("testuser123", "test@123", "test@abcd.com",
        "TestUser", new ArrayList<>(),"",null,null, Collections.singletonList("reader"));
System.out.println(request);
restTemplate.postForObject(URL, request, CreateUserRequest.class);

However on sending this request, I am getting the following error :

org.springframework.web.client.HttpClientErrorException$BadRequest: 400 Bad Request: [{"type":"ApiError","message":"Can not construct instance of org.graylog2.rest.models.users.requests.CreateUserRequest, problem: Null fullName\n at [Source: org.glassfish.jersey.message.internal.ReaderInterceptorExecutor$UnCloseableInputStream@a602d60; line: 1, column: 195]"}]

The error says that the fullName is null and that is the cause of the problem. However, in the above code snippet I have specifically mentioned the Full Name.
I also tried sending the request using the API browser and was getting the same error there.

Getting the same error while using the API browser. PFA the screenshot.

I figured the issue out. The issue was that I was using the instance of org.graylog2.rest.models.users.requests.CreateUserRequest to create the User. However this request was producing a JSON with a key “fullName” while the expected name of this key is “full_name” (notice the underscore in between).

So Instead of using the org.graylog2.rest.models.users.requests.CreateUserRequest to create the request body I had to use a custom POJO to generate the JSON which is consistent with the Graylog documentation.

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