Form submission using POST menthod | Community
Skip to main content
Amit_Jain
Community Advisor
Community Advisor
October 10, 2019
Question

Form submission using POST menthod

  • October 10, 2019
  • 4 replies
  • 11811 views

Is it possible to hit an form endpoint to submit the form? I was trying to do that using following URL:

https://xxxx.marketo.com/index.php/leadCapture/save2?formid=1234&munchkinId=xxx-xxx-xxx

but I'm getting error that form is not found? I also checked the documentation and found that it's not allowed to server side positing the data to a form.

Is there any other way to achieve this?

We are trying to integrate ManyChat.com with marketo and there is an option to post the data to en external system directly like a Marketo webhook. I can use the /lead REST API to creaeteOrUpdate but there will be an issue with the token since it's work just like Marketo webhook.

Thanks in advance for your input on this.

Regards,
Amit

4 replies

Amit_Jain
Community Advisor
Amit_JainCommunity AdvisorAuthor
Community Advisor
October 10, 2019

@Sanford Whiteman‌ probably you can help me out here.

SanfordWhiteman
Level 10
October 10, 2019

You can POST to /save (not /save2).

Use the case-sensitive core fields:

   munchkinId
   formid
   retURL (Thank You URL)
   _mkt_trk (Munchkin cookie)
_mktoReferrer (URL of the page w/form)‍‍‍‍‍

/save is the same endpoint used by <noscript> form posts from Marketo LPs, so it's not really exotic in any way. While you can't open a Support case about it (like other advanced and/or experimental tactics) it's a reliable part of the Marketo ecosystem, up to its rate limit (30 form posts per second minute per IP).

Amit_Jain
Community Advisor
Amit_JainCommunity AdvisorAuthor
Community Advisor
October 11, 2019

Thanks Sanford. I tried but it didn't work either in my case.

SanfordWhiteman
Level 10
October 11, 2019

Without seeing your code I can't tell you what's wrong. But it's a basic URL-encoded form POST.

Jay_Jiang
Level 10
October 11, 2019
https://xxxx.marketo.com/index.php/leadCapture/save2?formid=1234&munchkinId=xxx-xxx-xxx

You should be including the parameters in the body of the POST. Adding it to the URL is GET.

You can post to save2 server side (apparently you just need to add "formVid"). But warning that the anonymous IP address will be that of the server's and any inferred data will be incorrect.

CURL example in php

<?php
$fields = [
'formid'=>1234,
'formVid'=>1234,
'munchkinId'=>'xxx-xxx-xxx',
'Email'=>'abc@cba.com' // Email not email
];
$payload = '';
foreach($fields as $k=>$v) { $payload .= $k.'='.$v.'&';}
$payload = rtrim($payload , '&');
$ch = curl_init('https://xxxx.marketo.com/index.php/leadCapture/save2');
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
curl_close($ch);
?>
Amit_Jain
Community Advisor
Amit_JainCommunity AdvisorAuthor
Community Advisor
October 11, 2019

Hi Jay,

What is the purpose of formVid here? When I added this in the request, Marketo accepted it and before I was getting 404?

Regards,

Amit

SanfordWhiteman
Level 10
October 11, 2019

formVid is simply one of the required fields for the Forms 2.0 /save2 endpoint.

It's not required for the Forms 1.0 /save endpoint.

I recommend using /save because there will be fewer surprises, namely that only /save, last I checked, can be used from a Marketo instance to itself (which is used for deliberate duplicates and for cookie association).

Arpit_Arora-2
Level 1
October 15, 2019

Hi Guys,

Munchkin ID and Form ID are available on every Marketo LP by using that value anyone can create the spam leads in any marketo instance using the above method. Is there any way to stop that?  /save or /save2 should not work directly and do not create any lead?

Thanks!

SanfordWhiteman
Level 10
October 15, 2019

That's the way the Marketo forms endpoint works, Arpit.  (And the way any forms endpoint that doesn't specifically require a CSRF token works, not that's it's difficult to simulate a CSRF token.)

Arpit_Arora-2
Level 1
October 22, 2019

Thanks Sanford Whiteman‌, But I am not sure what are CSRF tokens and how it is connected to Marketo form submit.