SOLVED

Rest get to retrieve all fields of a lead

Go to solution
Anonymous
Not applicable

Rest get to retrieve all fields of a lead

Hi,

I want to retrieve value of all the fields available for a lead in marketo. Is there any generic api to get this or do i have to hard code all the field names in the url?when i am making a rest call with all the field names in url it is throwing a exception saying Url too long. Any pointers?

Tags (2)
1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

Re: Rest get to retrieve all fields of a lead

Use Content-Type as in my example. "Raw" is not appropriate here.

View solution in original post

10 REPLIES 10
Grégoire_Miche2
Level 10

Re: Rest get to retrieve all fields of a lead

Hi Manisha,

You can use the "describe" api that will give you the list of fields. See Describe » Marketo Developers

-Greg

Anonymous
Not applicable

Re: Rest get to retrieve all fields of a lead

I do not want a list of fields i want to pull data of all the fields for leads.e.g:for each lead i want to get all data that is there in marketo.

Grégoire_Miche2
Level 10

Re: Rest get to retrieve all fields of a lead

Use the the Get Lead by Id Get Lead by Id » Marketo Developers  or any other Get lead call.

But you will have to provide the list of fields you want to retrieve, so you will need to retrieve the field names first, hence my first answer.

-Greg

Anonymous
Not applicable

Re: Rest get to retrieve all fields of a lead

Yes that i have done already but when i am giving all the fields an exception is thrown saying the url is too large because there are so many fields. Hence my question.

SanfordWhiteman
Level 10 - Community Moderator

Re: Rest get to retrieve all fields of a lead

Use the POST payload instead.

Include the additional parameter method=_GET.

     _method=GET&fields=Email,Salutation,FirstName,..

Anonymous
Not applicable

Re: Rest get to retrieve all fields of a lead

can you share a sample post request with the payload? Not able to figure it out

SanfordWhiteman
Level 10 - Community Moderator

Re: Rest get to retrieve all fields of a lead

I did share it.

     POST /rest/v1/leads.json HTTP/1.1

     Content-Type: application/x-www-form-urlencoded

     _method=GET&fields=...

This is a standard HTTP form post. The _method emulation hint tells the server to parse the entity as an oversize GET.

Anonymous
Not applicable

Re: Rest get to retrieve all fields of a lead

pastedImage_1.png

pastedImage_2.png

This is how i tried.But unsuccessful.Can you tell what am i doing wrong?

SanfordWhiteman
Level 10 - Community Moderator

Re: Rest get to retrieve all fields of a lead

Use Content-Type as in my example. "Raw" is not appropriate here.