0

I am using the SOAP API using C# via a connected service in VS. I am authenticating using the username + password method, which means I have access to the entire SF account (this is not what I want). I would rather use the OAUTH token to authenticate, but there appears to be no method in the WSDL to achieve this. The reason I need to achieve this is because I have a testing BU and a live BU and need a separation of data.

As I have to authenticate with username + password, when I am getting data out, I am assigning the client IDs, however this does not work and will only target the parent account, example code below:

APIObject[] Results;
string requestID;
string status;
RetrieveRequest rr = new RetrieveRequest();
rr.ObjectType = "DataExtensionObject[153D8BF9-A401-4075-9BBF-ACC75F7683D5]";
ClientID rrclient = new ClientID();
rrclient.ID = 510006449;
rrclient.IDSpecified = true;
RetrieveOptions ro = new RetrieveOptions();
ro.Client = rrclient;
rr.Options = ro;
SimpleFilterPart sf = new SimpleFilterPart();
sf.SimpleOperator = SimpleOperators.equals;
sf.Property = "ContactKey";
sf.Value = new string[] { email };
rr.Filter = sf;
rr.Properties = new string[] { "FirstName" };
status = client.Retrieve(rr, out requestID, out Results);

The status returns as Error: Data extension does not exist: 153D8BF9-A401-4075-9BBF-ACC75F7683D5

The extension name is correct, if I move this data extension into the shared data extensions folder, so that the parent account can see it, the code above returns OK.

Does anyone know how I can target the child BU in the call, or, better yet, does anyone know how I can authenticate via OAUTH using the SOAP service reference?

4
  • To be clear is the issue only when you are using an token in your call?
    – EazyE
    Dec 10, 2021 at 14:48
  • This is when using username and password, I cannot pass the token as there is no method for this in the WSDL.
    – Phil
    Dec 10, 2021 at 16:14
  • you can use token with SOAP calls developer.salesforce.com/docs/marketing/marketing-cloud/guide/…. <soap:header> > <fueloauth>YOUR_ACCESS_TOKEN</fueloauth> </soap:header>
    – EazyE
    Dec 10, 2021 at 19:35
  • Yes this is true, but I won't be able to use this via a connected service, I would need to create the calls manually which is not what I am after
    – Phil
    Dec 13, 2021 at 8:29

1 Answer 1

0

Found the answer aftern much fiddling:

APIObject[] Results;
string requestID;
string status;
var retrieveRequest = new RetrieveRequest
{
    ClientIDs = new ClientID[] { new ClientID() { ID = 510006449, IDSpecified = true } },
    ObjectType = "DataExtensionObject[153D8BF9-A401-4075-9BBF-ACC75F7683D5]",
    Properties = new string[]
    {
        "SubscriberKey",
        "First Name",
        "Last Name"
    },
    Filter = new SimpleFilterPart
    {
        Property = "SubscriberKey",
        SimpleOperator = SimpleOperators.equals,
        Value = new string[] { email }
    },
};

You must log in to answer this question.

Not the answer you're looking for? Browse other questions tagged .