FuelSDK-CSharp icon indicating copy to clipboard operation
FuelSDK-CSharp copied to clipboard

Error deserializing Activity objects on Retrieve() call

Open rodelpontanares opened this issue 2 years ago • 1 comments

Here is a sample code that illustrates the issue for me (I did remove the connection info from the sample code).

using System;
using System.Collections.Generic;
using System.Collections.Specialized;
using System.Linq;
using System.ServiceModel;

using BarokziWorks;

using FuelSDK;

namespace TestConsole
{
    class Program
    {
        static void Main(string[] args)
        {
            var client = new ETClient(new NameValueCollection
            {
                { "clientId", "***" },
                { "clientSecret", "***" },
                { "accountId", "***" },
                { "authEndPoint", "***" },
                { "restEndPoint", "***" },
                { "soapEndPoint", "***" },
                { "useOAuth2Authentication", "true" }
            });

            RetrieveRequest rr = new RetrieveRequest();
            rr.ObjectType = "activity";
            rr.Properties = new[] { "sequence" };


            string status = null;
            List<AutomationActivity> list = new List<AutomationActivity>();

            using (var scope = new OperationContextScope(client.SoapClient.InnerChannel))
            {
                var msgHeader = System.ServiceModel.Channels.MessageHeader.CreateHeader("fueloauth", @"http://tempuri.org", client.AuthToken);
                OperationContext.Current.OutgoingMessageHeaders.Add(msgHeader);

                status = client.SoapClient.Retrieve(rr, out string requestID, out APIObject[] results);

                while (status.In("OK", "MoreResults") && results.Length > 0)
                {
                    list.AddRange(results.Where(r => r.PartnerProperties?[0].Name != "ErrorMessage").Cast<AutomationActivity>());
                    if (status == "MoreResults")
                    {
                        rr.ContinueRequest = requestID;
                        status = client.SoapClient.Retrieve(rr, out requestID, out results);
                    }
                    else
                        break;
                }
            }
        }
    }
}
`

rodelpontanares avatar Sep 24 '21 05:09 rodelpontanares

In the original post above, it appears the SOAP API recognizes the object type but the SDK probably does not or does not have an Activity type (just a guess).

So, I also tried using "automationactivity" for rr.ObjectType but the in this case it seems the SOAP API does not recognize the type.

image

rodelpontanares avatar Sep 24 '21 05:09 rodelpontanares