APIs & Integrations

Sam_TS
Participant

Contacts' Original Source not populating after Forms API POST

Hi!

We're sending some of our contacts (those that convert in-app) to Hubspot via the Forms API. About half of our contacts created this way are listed as coming from "Offline Sources." This is incredibly unlikely, as in-app page that triggers the API request has Hubspot tracking code on it itself, so at the minimum we would expect that page to be listed in the users' drill downs.

I have tried testing directly using cURL with no positive results. Testing steps include:

  1. Clear all browsing history, cookies, etc from browser.
  2. Tether internet connection to phone to avoid IP filtering
  3. Browse to a handful of pages containing our company's Hubspot tracking code
  4. Copy the hubspotutk cookie value from dev tools
  5. Replace the cookie value in the sample request body from the docs with my new cookie value
  6. Submit the following cURL command:
curl -d "firstname=TestContact&lastname=FormSub&email=formsub@hubspot.com&newcustomproperty=testing&hs_context%3D%7B%22hutk%22%3A%22HUBSPOTUTK_COOKIE%22%2C%22ipAddress%22%3A%22192.168.1.12%22%2C%22pageUrl%22%3A%22http%3A%2F%2Fdemo.hubapi.com%2Fcontact%2F%22%2C%22pageName%22%3A%22Contact%2BUs%22%2C%22redirectUrl%22%3A%22http%3A%2F%2Fdemo.hubapi.com%2Fthank-you%2F%22%7D" -H "Content-Type: application/x-www-form-urlencoded" -X POST https://forms.hubspot.com/uploads/form/v2/{HUBSPOT_ID}/{FORM_ID}

  1. Check the contact property, and see this: 34%20AM

The fact that the request works about half the time on production is odd. As is the fact that when it doesn't work on production, it is shown as "Offline Sources," but manually with cURL I'm seeing "No URL."

Any help is greatly appreciated.

Thanks,
Sam

0 Upvotes
1 Reply 1
cbarley
HubSpot Alumni
HubSpot Alumni

Contacts' Original Source not populating after Forms API POST

Hi @sam_topstep, I can't think of a reason off the top of my head that would indicate why in production this code would only work half of the time unless the contact was specifically meant to not be tracked. Navigating around my own site and submitting the same request you made to my own portal with my own hutk yielded a positive result on which page my contact submitted the form on and a successful association with a hubspot tracking cookie.

Here's my request in Postman:

URL: https://forms.hubspot.com/uploads/form/v2/3430672/983fd305-bdd3-40be-bc25-59be5f5650a8
BODY:
firstname=CONNOR&lastname=TEST&email=formtestingtesting3@testing.com&hs_context=%7B%22hutk%22%3A%22b1823d5a4f74016abee12bfc16aa8814%22%2C%22pageUrl%22%3A%22https%3A%2F%2Fdemo.hubapi.com%2Fcontact%2F%22%2C%22pageName%22%3A%22BLAHBLAH%22%2C%22redirectUrl%22%3A%22https%3A%2F%2Fdemo.hubapi.com%2Fthank-you%22%7D

HEADERS: Content-type: application/x-www-form-urlencoded

Here's my contact:

Make sure that your request is formatted properly with the body properly urlencoded as a malformed hs_context parameter is normally where I see most issues with the Forms API.

0 Upvotes