Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

Anonymous
Not applicable

Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

Hi

I've found a problem while playing around with Marketo SOAP API: in Marketo I see a field SFDC Type: which has a value Lead OR Contact.

But when I pull this lead via API I don't see this field. How do I know if what I'm pulling is a SFDC lead or SFDC Contact? Any work around here, or am I missing something

Tags (3)
12 REPLIES 12
John_Clark1
Level 10

Re: Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

Hi Paul,

Are you certain that the record you're pulling has been synced to SFDC?  It's possible that field is blank because the record only exists in Marketo.

John

Anonymous
Not applicable

Re: Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

Hi John

Yeah, I'm pretty sure. I created a contact and a lead in SFDC THEN waited for them to sync to Marketo THEN exported both via Soap API

And for neither of them there's any info on SFDC Type: even though it displays correctly in Mkto interface

PS: I'm doing a Soap GetLead API Call, and its not even that this field is empity, there's no such field at all, both for contacts and for leads

Grégoire_Miche2
Level 10

Re: Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

Hi Paul,

Are you sure you are using the right SFDC Type field ? There are 2 of them, one that gives you the lead/contact difference (and is empty when the lead exists only in Marketo), and the other that maps with the account.type standard field.

-Greg

Anonymous
Not applicable

Re: Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

Hi Greg,

the thing is, I'm not 'using' anything. I'm just pulling a lead via GetLead API call, and I don't get any info on SFDC Type: and look what I get:

stdClass Object

(

    [result] => stdClass Object

        (

            [count] => 1

            [leadRecordList] => stdClass Object

                (

                    [leadRecord] => stdClass Object

                        (

                            [Id] => 1000014

                            [Email] => guitarguy@guitar.com

                            [ForeignSysPersonId] =>

                            [ForeignSysType] =>

                            [leadAttributeList] => stdClass Object

                                (

                                    [attribute] => Array

                                        (

                                            [0] => stdClass Object

                                                (

                                                    [attrName] => Company

                                                    [attrType] => string

                                                    [attrValue] => Guitars

                                                )

                                            [1] => stdClass Object

                                                (

                                                    [attrName] => FirstName

                                                    [attrType] => string

                                                    [attrValue] => Guitar

                                                )

                                            [2] => stdClass Object

                                                (

                                                    [attrName] => LastName

                                                    [attrType] => string

                                                    [attrValue] => guy

                                                )

                                        )

                                )

                        )

                )

        )

)

Grégoire_Miche2
Level 10

Re: Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

And if you search the email guitarguy@guitar.com in the  lead database, what is the value of the field in the lead detail screen -> Lead Info Tab ?

Grégoire_Miche2
Level 10

Re: Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

Sorry, you checked already, from what I see above.

It should return much more data, not just these 3 fields if they are not empty in the database.

-Greg

Anonymous
Not applicable

Re: Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

Greg,

Any idea why that's not the case?

cheers,

Paul

Grégoire_Miche2
Level 10

Re: Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

Excepted for the fact that you could query the wrong lead, no.

Can you copy here the code you use to query ?

Sanford Whiteman​ may have an idea.

If not, this will required a support ticket I'm afraid.

-Greg

Anonymous
Not applicable

Re: Using SOAP API: How to differentiate SFDC leads from SFDC contacts?

I'm using:

class Marketo_Soap

{

private $_endpoint;

private $_user_id;

private $_secret;

private $_soap_client;

private $_soap_header;

public function __construct($endpoint, $user_id, $secret)

{

  $this->_endpoint = $endpoint;

  $this->_user_id = $user_id;

  $this->_secret = $secret;

}

public function get_lead($value, $by = 'id')

{

  $type = null;

  switch ($by) {

   case 'email': $type = 'EMAIL'; break;

   case 'id': $type = 'IDNUM'; break;

  }

  if (empty($type)) {

   throw new Exception('incorrect type');

  }

  $leadKeyParams = (object) array(

    'leadKey' => (object) array(

     'keyType' => $type,

     'keyValue' => $value

    )

  );

  $params = array('paramsGetLead' => $leadKeyParams);

  return $this->_call('getLead', $params);

}

private function _call($command, array $params, $test = false)

{

  try {

   return $this->_get_soap_client()->__soapCall($command, $params, $this->_get_soap_options(), $this->_get_header());

  } catch(Exception $ex) {

   throw $ex;

  }

}

private function _get_soap_client()

{

  if ($this->_soap_client === null) {

   $this->_soap_client = new SoapClient($this->_endpoint ."?WSDL", $this->_get_soap_options());

  }

  return $this->_soap_client;

}

private function _get_header()

{

  if ($this->_soap_header === null) {

   $marketoNameSpace        = "http://www.marketo.com/mktows/";

  

   // Create Signature

   $dtzObj = new DateTimeZone("America/Los_Angeles");

   $dtObj  = new DateTime('now', $dtzObj);

  

   $timeStamp = $dtObj->format(DATE_W3C);

   $encryptString = $timeStamp . $this->_user_id;

  

   $signature = hash_hmac('sha1', $encryptString, $this->_secret);

  

  

   // Create SOAP Header

   $attrs = new stdClass();

   $attrs->mktowsUserId = $this->_user_id;

   $attrs->requestSignature = $signature;

   $attrs->requestTimestamp = $timeStamp;

   $this->_soap_header =  new SoapHeader($marketoNameSpace, 'AuthenticationHeader', $attrs);

  }

  return $this->_soap_header;

}

private function _get_soap_options()

{

  return array(

    'location' => $this->_endpoint,

    'timeout' => 500,

    'trace' => true,

    'keep_alive' => true,

    'compression' => SOAP_COMPRESSION_ACCEPT | SOAP_COMPRESSION_GZIP

  );

}

}