Quantcast
Channel: CRM Development forum
Viewing all articles
Browse latest Browse all 8223

how to create a Record in CRM 2011 using Web Service??

$
0
0

i want to create a record in contact entity of CRM 2011 using the web service (i have added a service Reference - Organization.svc) i can create a simple record with specifying first name & last name  but when it comes to lokup or pick list or any other then normal string it is giving me error that

There was an error while trying to serialize parameter http://schemas.microsoft.com/xrm/2011/Contracts/Services:entity. The InnerException message was 'Type 'EntityReference' with data contract name 'EntityReference:http://schemas.microsoft.com/xrm/2011/Contracts' is not expected. Consider using a DataContractResolver or add any types not known statically to the list of known types - for example, by using the KnownTypeAttribute attribute or by adding them to the list of known types passed to DataContractSerializer.'.  Please see InnerException for more details.

I have only Added a service reference in VS 2010 project

URL :  http://servername:port/OrganizationName/xrmServices/2011/organization.svc?wsdl

 OrganizationServiceClient orgClient = new OrganizationServiceClient();
            orgClient.ClientCredentials.Windows.ClientCredential = new System.Net.NetworkCredential("user name", "password", "servername");
           

            Entity myContact = new Entity();
            myContact.LogicalName = "contact";
            createentity2011.ServiceReference1.AttributeCollection myAttColl = new createentity2011.ServiceReference1.AttributeCollection();

              EntityReference t = new EntityReference();
                t.LogicalName = "account";
                t.Id =new Guid(guid);            

myAttColl.Add(new KeyValuePair<string, object>("lastname", "Rana"));
myAttColl.Add(new KeyValuePair<string, object>("parentcustomerid", t));

myContact.Attributes = myAttColl;
           
              try
            {
                orgClient.Create(myContact);
            }
            catch (Exception ex){
            MessageBox.Show(ex.Message);
            }

please help its urgent


Viewing all articles
Browse latest Browse all 8223

Trending Articles



<script src="https://jsc.adskeeper.com/r/s/rssing.com.1596347.js" async> </script>