Re: Form submission using POST menthod

SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission using POST menthod

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

SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission using POST menthod

Remember to URL-encode the Email field.  Emails can contain characters that break URL parsing.

rajanikantsaner
Level 2

Re: Form submission using POST menthod

hI @Jay_Jiang : Where I will find this curl_init URL . how its generated?

I just tried with replace my marketo instance name with "https://xxxx.marketo.com"but its not working its show me following error message

{"error":true,"errorCode":400,"message":"Form error, no subscription ID"}

Thanks in advanced.

SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission using POST menthod

Using the forms /save endpoint in this way is now formally deprecated. So please don't consider this route. What, exactly (spare no detail) are you trying to do?

rajanikantsaner
Level 2

Re: Form submission using POST menthod

@SanfordWhiteman  thanks for the quick reply.

 

We want to push the data using website custom form to marketo specific form using php.  We tried to figure out how to do that. (Store method might be curl , soap or rest api ) previously we do it using curl in PARDOT and I am new to marketo so stuck on this.

I found soap api syncLead using php its stored data but we want to store data within specific web form which we have created.

so we have track from which website form data get captured and its eaiser for us we can filter with filloutforms in smart list.

Thanks in advanced!

SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission using POST menthod


We want to push the data using website custom form to marketo specific form using php.  We tried to figure out how to do but we want to store data within specific web form which we have created. so we have track from which website form data get captured and its eaiser for us we can filter with filloutforms in smart list.

There's no public, supported API endpoint for what you describe at this time. (There's one in the feature pipeline, but it's not public yet.)

 

Even with such an endpoint, simply consuming rate-limited API (REST or SOAP) calls wouldn't be resilient against DoS attacks: you must introduce a rate limiter within your app, or it will be easily overwhelmed. And you'll always have a limit that's far below the real-world peak, simply because there aren't enough REST/SOAP API calls in a day.

 

In any case, what you should be doing is using the Forms 2.0 JavaScript API — on the client side — to post a hidden Marketo form with your custom form's values, not trying to do this from the server side. You don't need to cURL anything!

rajanikantsaner
Level 2

Re: Form submission using POST menthod

@SanfordWhiteman  thanks for the reply.

We want to achieve the following functionality

https://www.zycus.com/knowledge-hub/whitepapers/designing-an-ap-shared-service-center-for-cost-contr...

like we have added custom form after data filled we have push data in to PARDOT using ajax + PHP using different page called. on successful submit we display different content on same page without page refresh as per visitor requirement. Using Form 2.0 javascript how we can do that because we didn't found more customization feature can you please share some example so it will helpful.

 

Thanks in advanced!

 

SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission using POST menthod


wn successful submit we display different content on same page without page refresh as per visitor requirement. Using Form 2.0 javascript how we can do that because we didn't found more customization feature can you please share some example so it will helpful.

You can do anything you want after success using an onSuccess listener function.

 

MktoForms2.whenReady(function(mktoForm){
  mktoForm.onSuccess(function(submittedValues,thankYouURL){
    // `submittedValues` is an Object with the vals just sent
    // `thankYouURL` is the server-generated URL which is decided by Form Editor choices
    // you can do anything you want with these values 

    // make sure to stop the default full-page redirect behavior 
    return false;
  });
});

 

rajanikantsaner
Level 2

Re: Form submission using POST menthod

Hi @SanfordWhiteman  thanks for the reply.

 

Using post method of java script API 2.0 works fine. but I when same thing we try to achieve using CURL code is as follows.

$curlURL = "https://xxxx.marketo.com/leadCapture/save"; // replace with our domain name on marketo
$fields = array('formid'=>1001, 'formVid'=>1001, 'munchkinId'=>'000-GIE-000', 'Email'=>'curlapi.com', 'FirstName'=>'curlapiFname', 'LastName'=>'curlapiLname', 'formName'=>'TOFU_Leads_Form');
$payload = '';

foreach($fields as $k=>$v) {
$payload .= $k.'='.$v.'&';
}

$payload = urlencode(rtrim($payload , '&'));

$ch = curl_init($curlURL);
curl_setopt($ch, CURLOPT_POST, 1);
curl_setopt($ch, CURLOPT_POSTFIELDS, $payload);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
$result = curl_exec($ch);
print_r($result);
curl_close($ch);

 

I have curiosity why its not working

SanfordWhiteman
Level 10 - Community Moderator

Re: Form submission using POST menthod

Since the feature is not supported and will be completely removed next year, it's not worth pursuing further.