How do I get a list of Lead Fieldnames using the API? | Community
Skip to main content
February 12, 2013
Solved

How do I get a list of Lead Fieldnames using the API?

  • February 12, 2013
  • 2 replies
  • 1166 views
Hi there,

I am stuck trying to get a list of lead fieldnames (Firstname, lastname, salutation, company etc.) using the API and the discussions about this topic only talked about geting a list of field names using the UI. 

Any ideas on how to do this? 

I have tried using the ParamsGetMObjects but using the paramsGetMObjects type = "Field" or "Fields" gave errors saying that "MObject type is unknown".

Here is the piece of code I am working with: 

            Marketo_WS_2_0.ParamsGetMObjects pgo = new Marketo_WS_2_0.ParamsGetMObjects();
            Marketo_WS_2_0.MObjCriteria moc = new Marketo_WS_2_0.MObjCriteria();
            moc.attrName = "*";
            pgo.mObjCriteriaList = new Marketo_WS_2_0.MObjCriteria[1];
            pgo.mObjCriteriaList[0] = moc;
            pgo.type = "Field"; 
            var resp = client.getMObjects(ws_header, pgo);


Thank you.
This post is no longer active and is closed to new replies. Need help? Start a new post to ask your question.
Best answer by
You can use the DescribeMObject API call to get back the list of API Fields.  Specify LeadRecord as the objectName.

Here is a sample REQUEST/RESPONSE XML

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mkt="http://www.marketo.com/mktows/">
   <soapenv:Header>
      <mkt:AuthenticationHeader>
         <mktowsUserId>XXXXXXXXXXXXXXXXXX</mktowsUserId>
         <requestSignature>XXXXXXXXXXXXXXXXXX</requestSignature>
         <requestTimestamp>2013-02-12T09:16:05-07:00</requestTimestamp>
      </mkt:AuthenticationHeader>
   </soapenv:Header>
   <soapenv:Body>
      <mkt:paramsDescribeMObject>
         <objectName>LeadRecord</objectName>
      </mkt:paramsDescribeMObject>
   </soapenv:Body>
</soapenv:Envelope>


<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.marketo.com/mktows/">
   <SOAP-ENV:Body>
      <ns1:successDescribeMObject>
         <result>
            <metadata>
               <name>LeadRecord</name>
               <description>Composite object composed of fields from Lead, LeadInterest, and Company</description>
               <isCustom>false</isCustom>
               <isVirtual>true</isVirtual>
               <fieldList>
                  <field>
                     <name>Email</name>
                     <description xsi:nil="true"/>
                     <displayName>Email Address</displayName>
                     <sourceObject>Lead</sourceObject>
                     <dataType>email</dataType>
                     <size>255</size>
                     <isReadonly>false</isReadonly>
                     <isUpdateBlocked>false</isUpdateBlocked>
                     <isName xsi:nil="true"/>
                     <isPrimaryKey>false</isPrimaryKey>
                     <isCustom>false</isCustom>
                     <isDynamic>false</isDynamic>
                     <dynamicFieldRef xsi:nil="true"/>
                     <updatedAt>2012-10-16T18:46:37-05:00</updatedAt>
                  </field>

                  <field>
                    ...
                  </field>

                  <field>
                    ...
                  </field>

               </fieldList>
               <updatedAt>2013-02-08T12:33:34-06:00</updatedAt>
            </metadata>
         </result>
      </ns1:successDescribeMObject>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>

2 replies

Accepted solution
February 12, 2013
You can use the DescribeMObject API call to get back the list of API Fields.  Specify LeadRecord as the objectName.

Here is a sample REQUEST/RESPONSE XML

<soapenv:Envelope xmlns:soapenv="http://schemas.xmlsoap.org/soap/envelope/" xmlns:mkt="http://www.marketo.com/mktows/">
   <soapenv:Header>
      <mkt:AuthenticationHeader>
         <mktowsUserId>XXXXXXXXXXXXXXXXXX</mktowsUserId>
         <requestSignature>XXXXXXXXXXXXXXXXXX</requestSignature>
         <requestTimestamp>2013-02-12T09:16:05-07:00</requestTimestamp>
      </mkt:AuthenticationHeader>
   </soapenv:Header>
   <soapenv:Body>
      <mkt:paramsDescribeMObject>
         <objectName>LeadRecord</objectName>
      </mkt:paramsDescribeMObject>
   </soapenv:Body>
</soapenv:Envelope>


<SOAP-ENV:Envelope xmlns:SOAP-ENV="http://schemas.xmlsoap.org/soap/envelope/" xmlns:xsi="http://www.w3.org/2001/XMLSchema-instance" xmlns:ns1="http://www.marketo.com/mktows/">
   <SOAP-ENV:Body>
      <ns1:successDescribeMObject>
         <result>
            <metadata>
               <name>LeadRecord</name>
               <description>Composite object composed of fields from Lead, LeadInterest, and Company</description>
               <isCustom>false</isCustom>
               <isVirtual>true</isVirtual>
               <fieldList>
                  <field>
                     <name>Email</name>
                     <description xsi:nil="true"/>
                     <displayName>Email Address</displayName>
                     <sourceObject>Lead</sourceObject>
                     <dataType>email</dataType>
                     <size>255</size>
                     <isReadonly>false</isReadonly>
                     <isUpdateBlocked>false</isUpdateBlocked>
                     <isName xsi:nil="true"/>
                     <isPrimaryKey>false</isPrimaryKey>
                     <isCustom>false</isCustom>
                     <isDynamic>false</isDynamic>
                     <dynamicFieldRef xsi:nil="true"/>
                     <updatedAt>2012-10-16T18:46:37-05:00</updatedAt>
                  </field>

                  <field>
                    ...
                  </field>

                  <field>
                    ...
                  </field>

               </fieldList>
               <updatedAt>2013-02-08T12:33:34-06:00</updatedAt>
            </metadata>
         </result>
      </ns1:successDescribeMObject>
   </SOAP-ENV:Body>
</SOAP-ENV:Envelope>
February 15, 2013
Thank you! That does the trick.