Avatar

problem adding new user .net

0

hello I have a problem to add a user through .net
before adding it I assign the group, companyGroup and securityGroup and it throws me the error: PostgresException: WebServerInvoker exception in a call to 'Add': 'Exception of type PostgresException occurred.' , it is a single user that I try to add.

Thank you

 

Hilda Rodriguez

Please sign in to leave a comment.

3 comments

0
Avatar

Hilda,

Would you be able to add the code snippet (removing any personal data such as username, password, database)?

Mauricio Muniz 0 votes
0
Avatar

Hi, yes

 

API pruebaApi = new API("user", "pass", null, "db", "host");
pruebaApi.Authenticate();
/*CARGAMOS LA INFORMACION DEL USUARIO*/
IList<UserDetails> userDetails;
userDetails = GetUserDetails();

/*OBTENEMOS LOS USUARIOS, GRUPOS Y PERMISOS*/
IList<User> existingUsers = pruebaApi.Call<List<User>>("Get", typeof(User)) ?? new List<User>();
IList<Group> allGroups = pruebaApi.Call<IList<Group>>("Get", typeof(Group)) ?? new List<Group>();
IList<Group> securityGroups = pruebaApi.Call<IList<Group>>("Get", typeof(Group), new { search = new GroupSearch(new SecurityGroup().Id) }) ?? new List<Group>();

foreach (UserDetails userDetail in userDetails) {
/*AGREGAMOS EL GRUPO AL USUARIO Y PERMISOS*/
User userAdd = userDetail.User;
userAdd.CompanyGroups = GetGroups(userDetail.OrganizationNodeNames.Split('|'), allGroups);
userAdd.SecurityGroups = GetSecurityGroups(userDetail.SecurityNodeName, securityGroups);

pruebaApi.Call<Id>("Add", typeof(User), new { entity = user });

Hilda Rodriguez 0 votes
0
Avatar

Hello Hilda,

It seems like you are trying to add a user by using the Import Users example available on the SDK reference website. I can see that you have made some changes to the code that might be causing issues with adding users. For example, you are trying to add the user in the code below, but "user" is not defined in the code snippet that you have provided.

pruebaApi.Call<Id>("Add", typeof(User), new { entity = user }); 

I would suggest you to download a fresh copy of the Import Users Example and use the CSV to add users to a database. The importUsers.csv also contains the proper structure of the user object that will be added to the database.

I have tested this on my database and I was able to add users successfully using this example.

Shivansh Singla 0 votes