Created by: Chris Bertrand on 16-03-2010 02:25:27 PM I am trying to add a exisiting user into a user group. When calling the updateUserGroup method i get the error "There was an error generating the XML document" it then states InnerException = {"Value of ItemsElementName mismatches the type of UpdateUserGroupReqAddMembers; you need to set it to ItemsChoiceType6.@addMembers."} Here is the code i used, i am setting the element name to add members so am confused as to why this is occuring. Using v7 UpdateUserGroupReq userGroup = newUpdateUserGroupReq(); userGroup.ItemElementName = ItemChoiceType62.name; userGroup.Item = Group; UpdateUserGroupReqAddMembers reqMems = newUpdateUserGroupReqAddMembers(); userGroup.ItemsElementName =newItemsChoiceType6[1]; userGroup.ItemsElementName[0] = ItemsChoiceType6.addMembers; XUserGroupMember mem = newXUserGroupMember(); mem.Item = UserID; XUserGroupMember[] mems = newXUserGroupMember[1];
Subject: RE: C# Error when adding Member to UserGroup Replied by: Chris Bertrand on 17-03-2010 10:24:00 AM Heres a nice function i made that does this.
public void addUserToGroup(String UserID, String Group) { //Do a quick check to see if they exist GetUserGroupRes res = new GetUserGroupRes(); //Add UpdateUserGroupReq userGroup = new UpdateUserGroupReq(); userGroup.ItemElementName = ItemChoiceType62.name; userGroup.Item = Group; UpdateUserGroupReqAddMembers reqMems = new UpdateUserGroupReqAddMembers(); userGroup.ItemsElementName = new ItemsChoiceType6[4]; userGroup.ItemsElementName[0] = ItemsChoiceType6.addMembers; XUserGroupMember mem = new XUserGroupMember(); mem.Item = UserID; XUserGroupMember[] mems = new XUserGroupMember[4]; mems.SetValue(mem, 0); reqMems.member = mems; userGroup.Items = new UpdateUserGroupReqAddMembers[4];
Find answers to your questions by entering keywords or phrases in the Search bar above. New here? Use these resources to familiarize yourself with the community: