Need help with HTTP POST to Cvent

Level 2

Need help with HTTP POST to Cvent

I recently posted a question about traveling down the vast rabbit hole that is Cvent's SOAP API. Well, after talking with Cvent some more, it turned out that it all could be easily avoided, by posting to their form.

I'm trying to go about it in one of two ways, both of which are not working so great, and I'm hoping I can get set straight here.

Method one: Posting on a Marketo form on a Marketo landing page, and then having a webhook called with a query string to Cvent's registration link. This should work, in theory, according to their documentation. But it's returning an error. I'm not sure if it's the formatting of my query string (though I don't believe it is), or an error with their side.

Method two: Using their posting form on our landing page, and then having a hidden Marketo form to update leads on our end. I've looked at the documentation available ( and MktoForms2 :: HTML form to Mkto form ), but it's not counting as a form fill or updating anything on the Marketo side.

This is a an extremely stripped-down example of what I'm using:

<!DOCTYPE html>



    <meta charset="utf-8">



      body {background:#fff;}



var htmlForm = MktoForms2.allForms()[0];


//These are the values which will be submitted to Marketo









    <div class="mktoText" id="exampleText" mktoName="Example Text Area">

<form name="TestRegForm" id="htmlForm" action="" method="post">





<TD><font color=red>*E-Code:</font></TD>

<TD><INPUT size=36 name=ecode></TD>

<TD>Event Stub Format: (88888888-4444-4444-4444-121212121212)</TD></TR>


<TD><font color=red>*First_Name:</font></TD>

<TD><INPUT size=30 name=first_name></TD>



<TD><font color=red>*Last_Name:</font></TD>

<TD><INPUT size=30 name=last_name></TD>



<TD><font color=red>*Email_Address:</font></TD>

<TD><INPUT size=30 name=email_address></TD>

<TD>Must be valid email format: (</TD>





<INPUT type="submit" value="Submit" name="submit_form">


<script src="//"></script>

<form id="mktoForm_0000" style="display:none;"></form>

<script>MktoForms2.loadForm("//", "123-XYZ-456", 0000);</script>




Yes? No? I notice my input names needed for Marketo aren't the same as the input names for these fields (ex: Marketo uses "FirstName" while Cvent uses "first_name")...could that be a thing? What about those example values, do I ditch those? how does it update those hidden fields if the input names aren't the same? Does that mean I need to create custom fields to match those? What about why it's not counting a form fill in the first place? aaah help...

Level 10 - Community Moderator

Re: Need help with HTTP POST to Cvent

Definitely a lot of stuff jumbled together here, Alex.

1. You can't reference the MktoForms2 object before the script that loads forms2.min.js, since that object is created by the Forms 2.0 library. So your code as written will never work, since it starts by trying to access MktoForms2.allForms()[0] but you don't load the library until the end of the page. You can see an error in your F12 Console accordingly.

2. MktoForms2.allForms()[0] means "the first Marketo Form to finish rendering." That's far too arbitrary. You should always know what form you're accessing, especially here where there's one specific hidden form you're trying to post.

3. You're adding blank hidden fields to the Marketo form. I don't know what this is intended to do because those fields will never post if they stay blank (and they don't need to start off blank).

4. A deeper JS problem: you're reassigning the global variable htmlForm to the Marketo form when it should be left as a reference to the form with id="htmlForm". You shouldn't ever do this: changing automatic (browser-created) variables to user variables is a bad move. But I also don't know what you're trying to accomplish logic-wise, because...

5. There's no submit listener attached to the raw HTML form, so you're not intercepting the HTML form post and redirecting it to the Marketo Ajax submit, nor submitting to both servers. It justs posts to Cvent now.

I think you should concentrate on the webhook because the JS is kind of getting out of hand.   

Just use a regular Marketo form with the required fields on it (including the Cvent Event Stub string, of course). 

Then it's easy to transform the Marketo fields into the Cvent form fields and post them via webhook. I put up a little tool you can use to determine the correct webhook POST payload:

HTMLForm :: Build form-encoded string via self-action

Naturally the values you're passing in the payload are all Marketo tokens, so if a field like {{Lead.ecode}} doesn't exist yet you need to have a Marketo custom field for it.

Level 2

Re: Need help with HTTP POST to Cvent

Gaaaaah... I went according to the documentation, but apparently I know just enough to hurt myself, I guess.

I did actually have the fields populated at one point (ex: "FirstName":"John" etc). I stripped it out when posting the sample code. Logic being that, I was afraid that those example values would get passed, instead of what was actually getting filled out in the form. I can put that back in though easily enough if they need to be there.

I do have custom fields for the 'ecode' (among others); my concern was more for standard fields that differed (ex: Marketo's FirstName to Cvent's first_name). I guess my question there is, the field names on the visible form need to match the field names that are the hidden fields, yes? Otherwise, how are the values going to get passed from the visible form to the hidden form's fields? I suppose the example I posted should have included the field names of the visible form, instead of "FirstName" "LastName" "Email".

On lines 9 thru 18, I more or less copied the regular documentation, except I updated "myForm" to "htmlForm," because I figured that part had to direct to the form ID; what else would 'myForm' be? Nothing else in my code is called 'myForm,' so my impression is that it correlated to the form ID. From there, it followed to me that line 17 was the 'listener.'

When i looked at your documentation here: MktoForms2 :: HTML form to Mkto form - I don't see a listener attached to the raw HTML form there that looks any different from what I did on my form, except I included the entire embed code instead of just the last two lines like on yours, and put the 'display:none;' inline. 

As to your second point, the payload looks to be formatted correctly on my end; here's the example payload: ecode={{lead.CventEcode}}&first_name={{lead.First Name}}&last_name={{lead.Last Name}}&email_address={{lead.Email Address}}&source_id=null&target=null&itsubmit_form=Submit (You'll notice there's two fields at the end; sourceID & target. According to the documentation: "The Source ID and Target Landing Page fields can be null, but must be included in the form.")

It's coming back as response code 200, so it's connecting, but I'm getting a response that's a bunch of HTML effectively saying there's been an error and I need to contact my Cvent support team. Which I did...and they can't seem to help me. I'd paste the response code dump, but it's a giant block of jibberish.

If the payload I'm passing looks correct though, then at least I know the issue is on their side and not mine.

Level 10 - Community Moderator

Re: Need help with HTTP POST to Cvent

They probably don't mean the 4-character string "null" but actually the empty string, i.e.


(you also have a typo in your query params, "itsubmit" instead of "submit")