Skip to main content

Error adding drivers with MyGeotab SDK

JVera-1874
Original Poster

I'm trying to add new drivers but allways get this error message, no way to find out what's the problem, any help?

Error adding user: 'TORO MELLA, RODRIGO'

WebServerInvoker exception in a call to 'Add': GenericException An undefined exception has occurred.

Please contact support for further assistance

 

Thnkserror_geotab_osoft

Join the conversation

You need to be logged in to reply to this post and participate in the Geotab Community discussions.

Top Answers

A few notes looking at your User JSON:

 

  • Properties that are Entities or collections of Entities like CompanyGroups must have their ID set. This is the only property on sub-entities that are referenced when setting them on something like User, the remainder are ignored. Your user's CompanyGroup, SecurityGroup and Group do not have their IDs set, which I think would cause an issue.
  • Your user's FirstName and LastName are not set.
  • Are you making these calls directly, or are you doing so via the NuGet SDK's API object? You shouldn't need to serialize the object yourself if you're handing it to API.CallAsync<TEntity>()
  • "ID" in general should not be an object in JSON, it will just be a string. The SecurityGroup's ID has a sub-property "Name" that is set with the group ID. It should be something like "Id": "MyStringId".
  • The SecurityGroup also has a very large number of SecurityFilters defined. These will all be ignored when setting the User object, try removing them.
  • If you are making these calls directly, I would recommend configuring your JSON serializer to avoid writing properties with a null value. You only need to include the properties with values you intend to set. If you're using the NuGet SDK's API object, you don't need to worry about this.

 

With all of that in mind, your entire object could look like this, obviously taking the Id's I've filled in and replacing them with the actual group ID where appropriate:

 

{ "EmployeeNo": "47980174N", "FirstName": "OMAR", "LastName": "COT BERENGUE", "Name": "COT BERENGUE, OMAR", "Password": ".p.4.$.s.w.0.r.d.", "IsDriver": true, "CompanyGroups": [ { "Id": "MyCompanyGroupId" } ], "SecurityGroups": [ { "Id": "GroupUserSecurityId" } ], "Groups": [ { "Id": "MyGroupId" }, { "Id": "MyOtherGroupId" } ] }

 

3 Replies

It's hard to say what could be causing the error without seeing any code or the way the users are structured.

 

That said, the first thing that comes to mind for Drivers is to make sure you specify the entity type 'User' when making the Add call. Last I knew, 'Driver' is of course an Entity type, but you can't work with it directly via API methods. You'd need to reference the base 'User' type and add them that way, which would still maintain any Driver-only properties you've set when you do.

JVera-1874
Original Poster

Hello, this what I do, but I get a generic error without any detailed message.

If I remove the username then I get an error that username is missing but if I put it then get a generic error

Please find attached the json I use

Thanks

069N3000008gKCDIA2.json

A few notes looking at your User JSON:

 

  • Properties that are Entities or collections of Entities like CompanyGroups must have their ID set. This is the only property on sub-entities that are referenced when setting them on something like User, the remainder are ignored. Your user's CompanyGroup, SecurityGroup and Group do not have their IDs set, which I think would cause an issue.
  • Your user's FirstName and LastName are not set.
  • Are you making these calls directly, or are you doing so via the NuGet SDK's API object? You shouldn't need to serialize the object yourself if you're handing it to API.CallAsync<TEntity>()
  • "ID" in general should not be an object in JSON, it will just be a string. The SecurityGroup's ID has a sub-property "Name" that is set with the group ID. It should be something like "Id": "MyStringId".
  • The SecurityGroup also has a very large number of SecurityFilters defined. These will all be ignored when setting the User object, try removing them.
  • If you are making these calls directly, I would recommend configuring your JSON serializer to avoid writing properties with a null value. You only need to include the properties with values you intend to set. If you're using the NuGet SDK's API object, you don't need to worry about this.

 

With all of that in mind, your entire object could look like this, obviously taking the Id's I've filled in and replacing them with the actual group ID where appropriate:

 

{ "EmployeeNo": "47980174N", "FirstName": "OMAR", "LastName": "COT BERENGUE", "Name": "COT BERENGUE, OMAR", "Password": ".p.4.$.s.w.0.r.d.", "IsDriver": true, "CompanyGroups": [ { "Id": "MyCompanyGroupId" } ], "SecurityGroups": [ { "Id": "GroupUserSecurityId" } ], "Groups": [ { "Id": "MyGroupId" }, { "Id": "MyOtherGroupId" } ] }

 

Still have questions?