using targetWorkspace in the SOAP API with PHP helper | Community
Skip to main content
November 21, 2013
Question

using targetWorkspace in the SOAP API with PHP helper

  • November 21, 2013
  • 5 replies
  • 1154 views
Is there more info on using the contextHeader in the API? 

It is listed in the WSDL:
http://app.marketo.com/soap/mktows/2_0?WSDL 

but I do not see anything about the context header in the marketo_api.php file.

When looking at the docs, I can't find too many specifics on using the contextHeader other than syncLead is the only API call that supports it.  Is it an additional parameter passed into the syncLead API call? 

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

5 replies

November 22, 2013
targetWorkspace will be "Default" if the instance does not have workspaces enabled otherwise you can select one the existing workspaces, including Default.
November 25, 2013
Can you provide an example of using the contextHeader in XML? 

Unless I'm missing something, it does not appear to be on the syncLead page for XML or PHP but is for JAVA
http://developers.marketo.com/documentation/soap/synclead/ 

thx!

November 25, 2013
Java
 
MktowsContextHeader headerContext = new MktowsContextHeader();
headerContext.setTargetWorkspace("default");


XML - complete call skeleton

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mkt="http://www.marketo.com/mktows/">
   <soapenv:Header>
      <mkt:MktowsContextHeader>
         <targetWorkspace>?</targetWorkspace>
      </mkt:MktowsContextHeader>
      <mkt:AuthenticationHeader>
         <mktowsUserId>?</mktowsUserId>
         <requestSignature>?</requestSignature>
         <requestTimestamp>?</requestTimestamp>
         <!--Optional:-->
         <audit>?</audit>
         <!--Optional:-->
         <mode>?</mode>
      </mkt:AuthenticationHeader>
   </soapenv:Header>
   <soapenv:Body>
      <mkt:paramsSyncLead>
         <leadRecord>
            <!--Optional:-->
            <Id>?</Id>
            <!--Optional:-->
            <Email>?</Email>
            <!--Optional:-->
            <ForeignSysPersonId>?</ForeignSysPersonId>
            <!--Optional:-->
            <ForeignSysType>?</ForeignSysType>
            <!--Optional:-->
            <leadAttributeList>
               <!--Zero or more repetitions:-->
               <attribute>
                  <attrName>?</attrName>
                  <!--Optional:-->
                  <attrType>?</attrType>
                  <attrValue>?</attrValue>
               </attribute>
            </leadAttributeList>
         </leadRecord>
         <returnLead>?</returnLead>
         <!--Optional:-->
         <marketoCookie>?</marketoCookie>
      </mkt:paramsSyncLead>
   </soapenv:Body>
</soapenv:Envelope>

November 26, 2013
bgomes,

We were able to solve this by modifying the sample code. I would suggest you add this to the sample code so others don't have to figure out something that has already been figured out.

For those who run into this issue, you can get passed this by modifying the sample code like we did.

        //Create SOAP Header
        $attrs = new stdClass();
        $attrs->mktowsUserId = $this->accessKey;
        $attrs->requestSignature = $signature;
        $attrs->requestTimestamp = $timestamp;
        $context = new stdClass();
        $context->targetWorkspace = $workspace;
        $soapHdr = array();
        $soapHdr[] = new SoapHeader(self::MKTOWS_NAMESPACE, 'MktowsContextHeader', $context);
        $soapHdr[] = new SoapHeader(self::MKTOWS_NAMESPACE, 'AuthenticationHeader', $attrs);


        //Create Soap Client and Set Headers
        $soapClient = new SoapClient($marketoSoapEndPoint ."?WSDL", $options);
        $soapClient->__setSoapHeaders($soapHdr);
        try {
              $result = $soapClient->__soapCall('syncLead', $params, $options);
        } catch(Exception $ex) {
             var_dump($ex);
        }

July 7, 2014
Is syncLead the only API call that supports setting the target workspace? What do you do if you need to pass a batch of leads into a specific workspace?