SOLVED

Server side form post examples

Go to solution
Anonymous
Not applicable

Server side form post examples

Hi,

Im trying to do some server side form post like in this link http://developers.marketo.com/blog/server-side-form-post/  but im getting an error 400.

Does anyone have any examples of this procedure? Theres no dokumentation on what parameters that needs to be send in the POST

1 ACCEPTED SOLUTION

Accepted Solutions
Mel_Dadoly
Level 4

Re: Server side form post examples

Hi Rasmus,

Server side form posts are not something Marketo supports so you won't find a lot of examples around. Instead we recommend using a background Marketo form submission as described here:

http://developers.marketo.com/blog/make-a-marketo-form-submission-in-the-background/

View solution in original post

16 REPLIES 16
Mel_Dadoly
Level 4

Re: Server side form post examples

Hi Rasmus,

Server side form posts are not something Marketo supports so you won't find a lot of examples around. Instead we recommend using a background Marketo form submission as described here:

http://developers.marketo.com/blog/make-a-marketo-form-submission-in-the-background/

View solution in original post

Anonymous
Not applicable

Re: Server side form post examples

Hi Rasmus Bidstrup,

I know this is unsupported by Marketo, but I've been in a similar situation where I had to use an alternative method to submit a form via POST. You'll need the following info based on this article:

http://app-xx00.marketo.com/index.php/leadCapture/save?munchkinId=xxx-xxx-xxx&formid=0000&Email=exam...leadCapture/save?munchkinId=xxx-xxx-xxx&formid=0000&Email=example@domain.com&returnLPId=-1

The string app-xx00 corresponds to your specific Marketo app instance, xxx-xxx-xxx is your value for munchkinId (again unique for your instance), and formid value is the Marketo form you want to POST to. When correctly submitted this returns a 302 error, but you'll see a "filled out form" event in the lead record corresponding to the email address you submitted. Any additional fields you may need to send just need to use the SOAP API name of the field. Optionally, you can also pass Marketo's cookie using "_mkt_trk"

When I test this structure in hurl.it, I get a successful form fill event recorded in Marketo (the system will automatically create or update a lead record as necessary).

SanfordWhiteman
Level 10 - Community Moderator

Re: Server side form post examples

http://app-xx00.marketo.com/index.php/leadCapture/save?munchkinId=xxx-xxx-xxx&formid=0000&Email=exam...leadCapture/save?munchkinId=xxx-xxx-xxx&formid=0000&Email=example@domain.com&returnLPId=-1

This URL implies a GET, not a POST. With some endpoints, either method can be used, but you may need to pass the canonical/default method as the _method param (_method=GET or _method=POST).

At the very least, even when not technically required, passing _method will show someone else looking at your code later that you're emulating another method due to technical restrictions (an example would be needing to pass a very large payload to a method that usually expects GET, so you POST the data but also include _method=GET to make the intent clear, as it is here).   More typically, this pattern is used to emulate truly unsupported methods like PUT.

Why are you GETting a forms endpoint, anyway?  It's rare that you would lack the control over the client needed to do a POST. Marketo webhooks support both, as of course do client-side form posts and XHRs.

Anonymous
Not applicable

Re: Server side form post examples

Hey Amelia Mango​,

I have a similar use case. I want to pass SumoMe email signups directly into Marketo, so I don't have to download/upload a csv each time (and can trigger an auto response email. SumoMe has an option to pass a form field as a POST variable so you can specify the URL and field to pass.

Screen Shot 2016-02-04 at 17.33.13.png

First off: your method seems to work so thanks for that!

The only problem I have is with being able to pass on the submitted email address in place of "example@domain.com'. In Hurl.it, I used "Email=$email" in place of those, and passed an email address as a parameter named 'email'. This works fine and shows up correctly in Marketo.

However, if I use this same method in SumoMe, it creates a lead in Marketo with an email address of "$email", so I must be missing something. I can get the URL to successfully post to my form, just not with the email address used in the form.

Basically: how do I have a dynamic parameter in here? As you can see, I'm not too familiar with this Any thoughts welcome!

Tom

SanfordWhiteman
Level 10 - Community Moderator

Re: Server side form post examples

According to the screenshot it's asking for the POST variable name, not the value.   The form value passed will be the lead's email address.

The name of the variable in Marketo is Email with an uppercase "E" -- in your example you have a lowercase "e."

Anonymous
Not applicable

Re: Server side form post examples

Thanks Sanford!

My question is, how do I get the value to submit? In Amelia's example below, there is a part that says Email=example@domain.com. How would I change the URL itself to allow for this value to change each time (assuming the field was mapped with the correct variable name)?

Do I omit the "Email=example@domain.com" part and let SumoMe fill it in somehow, or is there some sort of dynamic value that needs to be entered in the URL itself beforehand? Like 'Email=[insert thing here]"?

http://app-xx00.marketo.com/index.php/leadCapture/save?munchkinId=xxx-xxx-xxx&formid=0000&Email=exam...leadCapture/save?munchkinId=xxx-xxx-xxx&formid=0000&Email=example@domain.com&returnLPId=-1

Anonymous
Not applicable

Re: Server side form post examples

Hi Tom Lloyd

Expanding a bit on Sanford's comments above - the only documentation I could locate from SumoMe is pretty sparse on how this feature operates. Have you tested this yet with the correct parameter name (Email)?

My best guess would be that you set the "success redirect URL" value as http://app-xx00.marketo.com/index.php/leadCapture/save?munchkinId=xxx-xxx-xxx&formid=0000&returnLPId... and then set your variable name to "Email". My suggestion would be to first confirm your url structure in hurl.it or a similar testing tool - easier to debug in Sumo if you're 100% sure that your other details are correct.

This is assuming that SumoMe concatenates this information as [your success redirect url]&[variablename]=[email address submitted on the form]. If your POST works in hurl.it but not in Sumo, then you might want to check on one of the following:

a. URL encoding of the email address value - the @ symbol would have to be encoded, so SumoMe needs to send the email address as human%40thing.com instead of human@thing.com

b. It's possible that SumoMe structures the POST url as [your success redirect]?[variablename]=[email address], using the ? instead of &

You may be able to detect how Sumo formats the POST by substituting a requestb.in URL for testing - I've found it can be super helpful in debugging this type of issue.

Hope this helps!

SanfordWhiteman
Level 10 - Community Moderator

Re: Server side form post examples

This is assuming that SumoMe concatenates this information as [your success redirect url]&[variablename]=[email address submitted on the form]. If your POST works in hurl.it but not in Sumo, then you might want to check on one of the following:

a. URL encoding of the email address value - the @ symbol would have to be encoded, so SumoMe needs to send the email address as human%40thing.com instead of human@thing.com

b. It's possible that SumoMe structures the POST url as [your success redirect]?[variablename]=[email address], using the ? instead of &

No, this is the same confusion from earlier in the thread.  GET and POST are -- for the purposes of this integration -- starkly different.

When you tell SumoMe to send the email value as a GET variable (a.k.a. query parameter), it will append the name and value to the success URL.  That's where query params always go, by definition: in the URL.  It'll either be

     ?{variable name}={email entered by the lead}

if your redirect URL doesn't have any static params, or

     ?anotherparam=anothervalue&anotherparam2=anothervalue2&{variable name}={email entered by the lead}

if you manually add other static params to the URL.

When you tell SumoMe to send the email value as a POST variable, however, it is part of the body of the POST request that is sent to the success URL. Request bodies are not visible in the URL!  The data is indeed formatted as {variable name}={email entered by the lead} but is in the HTTP POST body.

In both cases the email address is properly URL-encoded.

SanfordWhiteman
Level 10 - Community Moderator

Re: Server side form post examples

As described above, when you choose "Pass email address as a GET variable" both the name (should be "Email" in a Marketo context, not "email") and the value (what the lead entered) are both appended to the URL automatically.  You don't create placeholders in the URL for them, they are added to the end.

However, this is definitely not the way you should integrate SumoMe. You shouldn't be redirecting immediately to the Marketo endpoint, regardless of whether you use GET or POST.  Why?  Because you'll be leaving out the very, very important component of the Munchkin cookie! If you do not pass the cookie, you will not have an associated Munchkin session.  All web activities will be anonymous. The form fillout will be a totally separate transaction. The lead will exist in your database, but you won't know any of their behaviors.

What you should instead do is GET to a page that in turn does a hidden form post, including the ​Munchkin cookie.