How to send form data to HubSpot using POST request

I’m working on a registration form and need help with posting the data to HubSpot’s API endpoint. I have a basic form set up, but I’m not sure how to configure the submit button to send a POST request to the HubSpot URL.

Here’s my current form structure:

@model CompanyPortal.Models.UserRegistrationViewModel
@using CompanyPortal.Models;

@using (Html.BeginForm("RegisterUser", "Registration", new { area = "CompanyPortal" }, FormMethod.Post)) {
<div class="container">
    <div class="col-12">
        <h2>User Registration Form</h2>
        <p>Complete the form below to create your account, or <a href="/contact/support">reach out to our team</a>.</p>
        <p class="note"><span class="required">*</span> indicates mandatory fields</p>
    </div>
    
    <div class="form-section">
        <div class="field-group">
            @Html.LabelFor(m => m.GivenName)
        </div>
        <div class="input-group">
            @Html.TextBoxFor(m => m.GivenName)
            <span class="required" title="This field is required">*</span>
        </div>
        
        <div class="field-group">
            @Html.LabelFor(m => m.FamilyName)
        </div>
        <div class="input-group">
            @Html.TextBoxFor(m => m.FamilyName)
            <span class="required" title="This field is required">*</span>
        </div>
        
        <div class="button-section">
            <div class="col-10 offset-1">
                <input type="submit" name="submitAction" value="Submit Registration" />
            </div>
        </div>
    </div>
}</div>

What’s the best way to configure this to post directly to HubSpot? Any suggestions would be helpful.

u should use HubSpot’s Forms API. set the action to https://forms.hubspot.com/uploads/form/v2/:portal-id/:form-guid. make sure the field names match HubSpot’s properties & add your API key if required.

Skip the API headaches and just use HubSpot’s embed code instead. Build your form directly in HubSpot, grab the embed code, and drop it on your page. I dealt with the same thing last year and this approach was way more reliable than trying to modify an existing form. HubSpot handles all the backend stuff automatically - leads flow into your CRM without any custom API work. You’ll also get spam protection and better analytics built-in.

I’ve dealt with this before - posting directly from the frontend usually breaks because of CORS issues. Keep your current form but change your RegisterUser action to handle the HubSpot submission server-side instead. Use HttpClient to send the data to HubSpot after you process it locally. You’ll get better error handling this way and can validate everything before it goes to HubSpot. Just map your model properties to HubSpot’s field names in the controller - don’t mess with your view markup.

This topic was automatically closed 24 hours after the last reply. New replies are no longer allowed.