Passing program tokens to requestCampaign

Anonymous
Not applicable

Passing program tokens to requestCampaign

I am trying to use the SOAP API to send emails using the requestCampaign method. I can't seem to get Marketo to replace the tokens in my programTokenList. I received the following error:

Parameters should be either (source, campaignId, leadList) or (source, programName, campaignName, leadList, programTokenList) (20114)

If I make the call and only pass the source, campaignId, and leadList parameters, it works, and sends the email as expected (with all of the default values for tokens). If I try the other method suggested in the error message, I get the same error.

I used the SOAP API getCampaignsForSource to get my campaign name, but I've also tried every other variation. For example, I have a program called Send Email via API, and a campaign called Send Email. I've tried passing those values to programName and campaignName, respectively, but also null for programName and Send Email via API.SendEmail for the campaignName. 

How can I pass the tokens correctly? The following is an example of the code I'm using:

var response = appBinding.requestCampaign(new ParamsRequestCampaign
                    {
                        campaignIdSpecified = false,
                        programName = "Send Email via API",
                        campaignName = "Send Email via API.Send Email",
                        source = ReqCampSourceType.MKTOWS,
                        leadList = new[]
                            {
                                new LeadKey
                                    {
                                        keyType = LeadKeyRef.IDNUM,
                                        keyValue = Convert.ToString(leadId)
                                    }
                            },
                        programTokenList = new[]
                            {
                                new Attrib
                                    {
                                        name = "{{my.Subject}}",
                                        value = saveCartUrl
                                    }
                            }
                    });
Tags (1)
3 REPLIES 3
Anonymous
Not applicable

Re: Passing program tokens to requestCampaign

After some further analysis with fiddler, I found out I was still hitting the v1.7 endpoint, and not the 2.1 endpoint. After updating, everything worked as expected.
Not_needed
Level 1

Re: Passing program tokens to requestCampaign

How to hit the 2.1 endpoint? I am getting same error when adding programTokenList in XML request body

Tags (1)
SanfordWhiteman
Level 10 - Community Moderator

Re: Passing program tokens to requestCampaign

I have to ask why you’re using the SOAP API, which is both deprecated and dangerous from a security standpoint, instead of the REST API?