Avatar

How to add group with parent "Company Group" using c# sdk

0

customerGroup = new Group();
customerGroup.Name = "CUSTOMER";
customerGroup.Parent = getGroup(api, "Company Group", null);  //Company group is the parent group in which node has to be entered
customerGroup.Id = api.Call<Id>("Add",typeof(Group), new { entity = customerGroup });

 

and we are getting Error:

WebServerInvoker exception in a call to 'Add': 'System.Collections.Generic.Dictionary`2[System.String,System.Object]'

 

sharique

Please sign in to leave a comment.

11 comments

Avatar

You have to give it a color.

Group newGroup = new Group();

newGroup.Name = "whatever";

newGroup.Parent = new Group() { Id = KnownId.GroupCompanyId };

newGroup.Color = Color.FromName("Yellow");

newGroup.Id = AddGroup(newGroup);

 

where AddGroup is making the api call to add the group and returning the Id.

 

Michael

0
Michael Head 0 votes
Avatar

Hi,

 

Thanks for your reply,

will you please give some reference for "how to get group by its name and parent id"

my code is :

List<Group> groups = api.Call<List<Group>>("Get", typeof(Group), new
{
search = new GroupSearch
{
Name = groupName

}
});

 

but i also want to filter groups by its parent Id

0
sharique 0 votes
Avatar

You can use an exact name or use % at the beginning and end of your string to search for a group name that contains your group name search.

You can't use a filter on a group for parent.  You would have to retrieve them and then filter on the client side either by parent or by children ids.

0
Michael Head 0 votes
Avatar

 here i am calling set function.

"api.Call<Device>("Set", typeof(Device), new { entity = device });"

 

and i am getting error:

"IllegalArgumentException: WebServerInvoker exception in a call to 'Set': 'Unknown device type'"

0
sharique 0 votes
Avatar

Actually your call should have worked originally.  YOu need to look at your object.  Did you modify the device.DeviceType?  Look and see what value you have for that.  Can you post your code from the retrieval of the device to the update of the device. 

0
Michael Head 0 votes
Avatar

So this should work but check your object:

"api.Call<Device>("Set", typeof(Device), new { entity = device });"

0
Michael Head 0 votes