Push leads to Marketo via REST API - help with structuring the URL? | Community
Skip to main content
April 5, 2017
Solved

Push leads to Marketo via REST API - help with structuring the URL?

  • April 5, 2017
  • 1 reply
  • 7378 views

Hello fine members of Marketo Nation!

I am once again in need of your help. I'm trying to help a 3rd party push leads to our Marketo instance via the REST API, and I'm struggling to get it to work. Thing is, in the past, we got it to work with another company, and they provided a clip of the string they used, so I thought "hey we can totally use that in this instance too" since this client is trying to do the same thing. Ha! If only it were so easy!

Anyway, here's what they're sending to us:

https://[exampleEndpoint].mktorest.com/rest/v1/leads/push.json?access_token=[ourToken]&[customField]=value&firstName=John&lastName=Smith&postUrl=https://350-yae-212.mktorest.com/rest/v1/leads.json&emailAddress=test@test.com&clientId=[clientId]&tokenUrl=https://[exampleEndpoint].mktorest.com/identity/oauth/token&secretKey=[secretKey]&grant_type=client_credentials&action=createOnly​

And here is the error that's returned:

{"requestId":"[insert numbers here]","success":false,"errors":[{"code":"1001","message":"For input string: \"push\" failed to convert to a number"}]}

Okay, so, I looked that error code up, and my impression is that it's assigning a bad field type somehow. (trying to convert a string to an integer? or am I totally off base here?) I've got no idea where to even start here, though, since I'm not sure what it looks like on their side to push the lead to us to begin with. Am I forming the URL incorrectly? If there's no way for me to test it in my side (though I can return the same error if I just click on the link in my browser), is there a direction I can point them in for doing it correctly?

Uggh databases, amirite?

Til next time,

-Alex

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 SanfordWhiteman

There definitely seems to be a gap in knowledge on this front, unfortunately. I'm going to suggest the webhook, though I'm interested in learning more about 2-phase commit.

I scanned the product docs for info on 2-phase commit, but didn't find anything that made sense with the form API. Would you be able to describe further, or point me in the right direction with some links?


You wouldn't find such a concept explicitly in the Marketo docs.

But the nature of the Forms 2.0 API is such that it can submit form data to Marketo, even if that data was entered on a non-Marketo custom form (either a basic HTML form or a form managed by some other JS forms library).

So by catching the form submission event, you can send form data to Marketo as well as to the form's default destination. That's the kind of thing going on here in a demo related to another Nation post from earlier today.

1 reply

SanfordWhiteman
Level 10
April 5, 2017

That's... a lot of things jumbled together.

A Push Leads endpoint looks like this:

https​://123-abc-456.mktorest.com.rest/v1/leads/push.json

It accepts

     Content-Type: application/json

This is all in the docs. I hope the 3rd party is looking at the developer docs: as sparse as they can be, it's a lot worse without them.

Note you shouldn't use Push Leads if it can be at all avoided. For example a 3rd party form should use the Forms API. 

April 5, 2017

I've sent them the product docs, and this is what they came up with after reading it. Hearing that it is nonsensical does help put us in the right direction. I often feel like I'm taking random stabs in the dark with this particular subject...

I agree that the Forms API makes a lot more sense, and this is usually the first solution I put forward in this situation. However, what's happening here is that the 3rd party is an affiliate site, and they send us the leads, which we're paying for. So they want to be able to track the leads. Would it make sense then for me to create a webhook to push leads to them instead?

SanfordWhiteman
Level 10
April 5, 2017

If they only have access to the final lead info on their back end (i.e. they must do post-processing before sending them to you), then sadly the Push Leads endpoint is as good as you're going to get.

But if they looked at the docs and that's what they came up with, they don't seem like they have the skills for this.

If you could reverse it so you get the leads first, you could certainly use a webhook to push lead info to them (for example, posting to their forms endpont).

Or a single form could even be used to push leads to their side (using whatever) and to your side (using the Forms API), a form of 2-phase commit.