SOLVED

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

Go to solution
Anonymous
Not applicable

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

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]...

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

1 ACCEPTED SOLUTION

Accepted Solutions
SanfordWhiteman
Level 10 - Community Moderator

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

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.

View solution in original post

8 REPLIES 8
SanfordWhiteman
Level 10 - Community Moderator

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

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. 

Anonymous
Not applicable

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

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 - Community Moderator

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

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.

Anonymous
Not applicable

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

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?

SanfordWhiteman
Level 10 - Community Moderator

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

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.

Anonymous
Not applicable

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

Excellent info!

So if I'm understanding correctly, I'd have them do the following:

  • Provide our HTML form embed (which I'd include a style tag of "display:none;")
  • Provide the JS snippet from the link, updating the form ID to the ID from the embed code, the 'formSelector' to the 3rd party's form, and the 'fieldMap' to map the Marketo fields to the form fields displayed on their end
  • Form data gets submitted to Marketo simultaneously upon clicking 'submit'
  • ????
  • Profit!

If so, that seems fairly straightforward, and a far easier solution than trying to implement push.json.

You've been a lifesaver, Sanford. Can't say how much I've appreciated all your help!

SanfordWhiteman
Level 10 - Community Moderator

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

Yep, but there's one other thing to consider: the code in the demo uses

     e.preventDefault()

to stop the original (3rd party) form from submitting at all.

If you still want that form to submit you have to wait for the Marketo form to submit, then (in the Marketo form's onSuccess) trigger the 3rd party form to continue on its way.

Anonymous
Not applicable

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

I see, so if that line is in there, it'll submit to Marketo, but not to the form's original destination, correct? In that case, all I'd need to do is remove that, and then it would submit to both simultaneously?

(Thank you for your patience with all the questions, I'm pretty sure I've got it figured out but wanted to be 100% before I go implementing the solution!)