Create new user using API

diagnoz7 days ago

Im trying to create a new user on the server, post request bellow, but I get security error (im creating just a regular user not an admin), why?

{
  "id": 0,
  "name": "Иван Иванов",
  "email": "ivan@example.com",
  "phone": "+79991234567",
  "readonly": false,
  "map": "osm",
  "latitude": 55.7558,
  "longitude": 37.6173,
  "zoom": 12,
  "password": "securePassword123",
  "coordinateFormat": "dd",
  "disabled": false,
  "expirationTime": "2030-01-01T00:00:00Z",
  "deviceLimit": 10,
  "userLimit": 5,
  "deviceReadonly": false,
  "limitCommands": false,
  "fixedEmail": false,
  "poiLayer": "",
  "attributes": {}
}

Cannot invoke "org.traccar.model.User.getAdministrator()" because the return value of "org.traccar.api.security.PermissionsService.getUser(long)" is null - NullPointerException (PermissionsService: 78 < *: 183 < UserResource: 92 < ... < OverrideFilter: 49 < ...)

Anton Tananaev7 days ago

The error seems to indicate that you're logged in with a user that doesn't exist anymore.

diagnoz6 days ago

This is an HTTP POST request, which means that I am not logged in.

Should I send authorities (admin for example or something like that) headers in HTTP?

Anton Tananaev6 days ago

This is an HTTP POST request, which means that I am not logged in.

This statement doesn't make sense to me. How are two things related? You can send a post request logged in or logged out.

diagnoz6 days ago

No, a request can't be logged in or out — it's probably missing a token or authorization info.