FuelSDK-CSharp
FuelSDK-CSharp copied to clipboard
Error deserializing Activity objects on Retrieve() call
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;
}
}
}
}
}
`
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.