locked
CRM data serialisation error on executemultiple RRS feed

  • Question

  • Hi Team,

    Error in line 1 position 421. Element 'http://schemas.datacontract.org/2004/07/System.Collections.Generic:value' contains data from a type that maps to the name 'Plugins:ExecuteMultipleRequest'. The deserializer has no knowledge of any type that maps to this name. Consider changing the implementation of the ResolveName method on your DataContractResolver to return a non-null value for name 'ExecuteMultipleRequest' and namespace 'Plugins'

    I got above error Code onexecuting below code.

      if (context.InputParameters.Contains("Target") && context.InputParameters["Target"] is Entity)
                {
                    
                    ExecuteMultipleSettings Settings = new ExecuteMultipleSettings();
                    Settings.ContinueOnError = false;
                    Settings.ReturnResponses = true;
                    ExecuteMultipleRequest executemultiple = new ExecuteMultipleRequest()
                    {
                        Requests = new OrganizationRequestCollection()
                    };
                    EntityCollection Etycollection = GetCollectionOfEntitiesToCreate();
                    foreach (Entity item in Etycollection.Entities)
                    {
                        CreateRequest createrecords = new CreateRequest() { Target = item };
                        executemultiple.Requests.Add(createrecords);
                    }
                    OrganizationRequest req = new OrganizationRequest();
                    req.RequestName = "ExecuteMultipleRequest";
                    req.Parameters.Add(new KeyValuePair<string, object>("create", executemultiple));                
                    OrganizationResponse executemultipleresponse = new OrganizationResponse();
                    //executemultipleresponse = service.Execute(req);
                    service.Execute(req);
                  // Console.WriteLine(executemultipleresponse);

                }


    Naveen

    Sunday, November 24, 2013 4:57 PM

All replies

  •  Hi naveen,

         in your service class for OrganizationRequest add KnownTypeAttribute for ExecuteMultipleRequest.

       By the way is this code working now? I see that you declared ExecuteMultipleSettings  and ExecuteMultipleRequest  but havent used it anywhere. how are you passing ExecuteMultipleSettings  and ExecuteMultipleRequest  to request. 

       Please let me know if you resolved this issue. I am working on same so help me if you already got solution. It will be helpful if you give code snippet in your reply.

     

        


    Thanks Regards Prashanth Kamasamudram Even the least work done for others awakens the power within; even thinking the least good of others gradually instills into the heart the strength of a lion.

    Monday, January 20, 2014 7:04 AM
  •   Finally I got it working....Following is the cod snippet. Any one who is facing same issue can refer this.

         

                ExecuteMultipleSettings Settings = new ExecuteMultipleSettings() { ContinueOnError = true, ReturnResponses = true };
                OrganizationRequestCollection Requests = new OrganizationRequestCollection();
                foreach (Entity e in deserializedContact.Entities)
                {
                    OrganizationRequest req1 = new OrganizationRequest();
                    req1.RequestName = "Create";
                    req1.Parameters = new ParameterCollection();
                    req1.Parameters.Add(new KeyValuePair<string, object>("Target", e));
                    Requests.Add(req1);
                }
                OrganizationRequest req = new OrganizationRequest();
                req.RequestName = "ExecuteMultiple";
                req.Parameters = new ParameterCollection();
                req.Parameters.Add(new KeyValuePair<string, object>("Settings", Settings));
                req.Parameters.Add(new KeyValuePair<string, object>("Requests", Requests));
                OrganizationResponse respo = client.Execute(req);
                XmlDocument orgResponceXML = SerializeEntityToXML(respo);


    If you face problem with Types, add following to  OrganizationResponce in Reference.cs

        [System.Runtime.Serialization.KnownTypeAttribute(typeof(ExecuteMultipleSettings))]
        [System.Runtime.Serialization.KnownTypeAttribute(typeof(OrganizationRequestCollection))]
        [System.Runtime.Serialization.KnownTypeAttribute(typeof(OrganizationResponseCollection))]
        [System.Runtime.Serialization.KnownTypeAttribute(typeof(Entity))]

    And for OrganizationRequest

        [System.Runtime.Serialization.KnownTypeAttribute(typeof(ExecuteMultipleSettings))]
        [System.Runtime.Serialization.KnownTypeAttribute(typeof(OrganizationRequestCollection))]
        [System.Runtime.Serialization.KnownTypeAttribute(typeof(Entity))]

    Thanks Regards Prashanth Kamasamudram Even the least work done for others awakens the power within; even thinking the least good of others gradually instills into the heart the strength of a lion.



    Monday, January 20, 2014 7:43 AM