Skip to main content
June 22, 2013
Question

Using Tokens with requestCampaign soap API call

  • June 22, 2013
  • 5 replies
  • 987 views
Hi All

I'm trying to send token value in the requestCampaign SOAP API call.

Following is the array which is generated for token:

[programTokenList] => ArrayOfAttrib Object
                (
                    [attrib] => Array
                        (
                            [0] => Attrib Object
                                (
                                    [name] => {{my.Subject}}
                                    [value] => Here are the NOTES
                                )
 
                        )
 
                )


When I run the script it gives the following error.
Fatal error:  Uncaught SoapFault exception: [SOAP-ENV:Client] 20114 - Bad parameter 
SoapClient->__soapCall('requestCampaign', Array, Array, Object(SoapHeader))
 
Marketo->request('requestCampaign', Object(stdClass))

What could be the reason for this, and how can I fix it.

Thanks
Himanshu
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.

5 replies

June 24, 2013
Just by initial glance, try using just the name of the token (assuming you created a Token on the program called Subject).  For example use Subject instead of {{my.Subject}}

Also note that providing the actual SOAP Request XML would allow for troubleshooting.  Here at Marketo, we use tools such as SOAP UI to test SOAP REQUEST/RESPONSE Messages.  

You can also use a tool like Wireshark to monitor the traffic between your specific SOAP Client code and see the Request XML that actually gets sent over to Marketo.
June 24, 2013
Himanshu,
Do you have a token named my.Subject in the program which contains the campaign you are requesting?

Raj
August 19, 2013
Similar problem:

var result = ws.requestCampaign(ai, new Marketo.ParamsRequestCampaign()

            {

                campaignId = campaign,

                campaignIdSpecified = true,

                source = Marketo.ReqCampSourceType.MKTOWS,

                leadList = new Marketo.LeadKey[]{new Marketo.LeadKey()

                {

                    keyType = Marketo.LeadKeyRef.IDNUM,

                    keyValue = lead.Id.ToString()

                },

                },

                programTokenList = new Marketo.Attrib[] {

                    new Marketo.Attrib() { name="EmailLinkUrl", value="http://staging.windstreambusiness.com/download?url=somefile"}

                }

            });


Campaign request work without the token, program it belongs to had the EmailLinkUrl defeined as a token, but I just get a Bad Parameter error back.  I coul'd have swore it worked in my initial trials but no luck now, I'm forced to go and generate extra Custom Fields to use.
August 19, 2013
Here's sample code that works -


public function testRequestCampaignOverrideTokens()

  {

       $key = new LeadKey();

       $key->keyType"EMAIL";

       $key->keyValue = "aahsan99@gmail.com";

       $key2 = new LeadKey();

       $key2->keyType"EMAIL";

       $key2->keyValue = "agha@marketo.com";

       $leads = array();

       $leads[] = $key;

       $leads[] = $key2;

       $leadList = new ArrayOfLeadKey();

       $leadList->leadKey = $leads;

 

       $tokens = array();

       // The {{ }} are optional, but 'my.' is required

       $tokens[] = new Attrib("{{my.Offer Start}}","1/1/2013");

       $tokens[] = new Attrib("{{my.Offer End}}","10/1/2013");

       $tokenList = new ArrayOfAttrib($tokens);

 

       $params = new paramsRequestCampaign();

       $params->source = "MKTOWS";

       $params->campaignName = "My Cool Campaign";

       $params->programName = "Winter 2013";

       $params->programTokenList = $tokenList;

       $params->leadList = $leadList;

 

       $authHdr = apiClientUtil::getAuthenticationHeader(self::$wsUser, null, null, $params);

  

       $client = $this->getSoapClient();

       $success = $client->__soapCall('requestCampaign', array($params), null, $authHdr);

  

       $this->assertNotNull($success, 'Response is null');

       $this->assertNotNull($success->result, 'Result in response is null');

       $this->assertTrue($success->result->success, 'API failure reported');

  }

July 29, 2014
FYI: You have to use the campaignName and programName parrameters to use tokens.  You can use the campaignId.  I ended up using getCampaignsForSource() to convert my campaing Id into the program Name and campaign Name.