locked
The request failed with HTTP status 400 RRS feed

  • Question

  • my question is
     dubbing of plug in error will generate The request failed with HTTP status 400: Bad Request. in this line 
     RetrieveResponse rr = (RetrieveResponse)crmService.Execute(retrieveRequest);

    my code is:
    using System;
    using System.Collections.Generic;
    using System.Linq;
    using System.Text;
    using Microsoft.Crm.Sdk;
    using Microsoft.Crm.Sdk.Query;
    using Microsoft.Crm.SdkTypeProxy;

    namespace UndeliveredEmailTrack
    {
        public class UndeliveredEmailTrack : IPlugin
        {
            public void Execute(IPluginExecutionContext context)
            {


                DynamicEntity entity = null;
                if (context.InputParameters.Properties.Contains("Target") && context.InputParameters.Properties["Target"] is DynamicEntity)
                {
                    entity = (DynamicEntity)context.InputParameters.Properties["Target"];


                    if (entity.Name == "email")
                    {

                        DynamicEntity[] mailfrom = (DynamicEntity[])entity.Properties["from"];
                        DynamicEntity party = mailfrom[0];
                        Lookup fromlookup = (Lookup)party.Properties["partyid"];
                        Guid queueid = fromlookup.Value;
                          string mailto = entity.Properties["to"].ToString();
                        string body = entity.Properties["description"].ToString();
                        string[] split = body.Split(new char[] { '/', ' ' });
                        int i = split.Length;
                        string s1 = split[0];
                        string s2 = split[1];

                        DynamicEntity ent = RetrieveEntity(queueid, context);

                    }
                }
            }
          
     public DynamicEntity RetrieveEntity(Guid guid, IPluginExecutionContext context)
            {
                ICrmService crmService = context.CreateCrmService(true);

                TargetRetrieveDynamic target = new TargetRetrieveDynamic();
                target.EntityId = (Guid)guid;
                target.EntityName = "queue";
                RetrieveRequest retrieveRequest = new RetrieveRequest();

                retrieveRequest.ReturnDynamicEntities = true;
                retrieveRequest.ColumnSet = new AllColumns();
                retrieveRequest.ReturnDynamicEntities = true;
                retrieveRequest.Target = target;
                // RetrieveResponse retrieveResponse = null; 
                //retrieveResponse = (RetrieveResponse)crmService.Execute(retrieveRequest); 
                RetrieveResponse rr = (RetrieveResponse)crmService.Execute(retrieveRequest);
                DynamicEntity roomoccupation = (DynamicEntity)rr.BusinessEntity;
                return roomoccupation;



            }
        }
    }
    • Moved by Donna EdwardsMVP Wednesday, February 10, 2010 2:11 PM (From:CRM Deployment)
    Monday, February 8, 2010 10:58 AM

Answers

All replies