APIs & Integrations

Steve-a-reno
Participant

Failure to create submission in form

I have been pushing data to a form for two years using the API and I get a 204 http response but the data is suddenly no longer being added to the form submissions. How can I find out why the submissions are no longer being added?

0 Upvotes
7 Replies 7
Steve-a-reno
Participant

Failure to create submission in form

Okay, I might have a fix for the issue.
So far it seems to be working again.

Here's what I found:
In wordpress, the url's for some of my product links were passed by wordpress like the following:
"https%3A%2F%2Fwww.mywebsite.com"

I also had some other special characters like a registration mark "®" (but passed as %AE).

In my case the problem seems to be the urlencoded or "safe" version of the URL's and Registration marks.
While the web safe urlencoded path is fine in the JSON data, in the regular portion of the data string, you need to change it to the standard https://www.mywebsite.com. Also look for any other special characters and fix that as well.

So your submission code would look like the following:
$first_name = 'John';
$last_name = 'Smith';
$website = 'http://www.mywebsite.com';

$hs_context = array(
'firstname' => '$first_name',
'lastname' => '$last_name',
'website' => 'http://www.mywebsite.com'
);
$hs_context_json = json_encode($hs_context);
$str_post = "firstname=" . urlencode($first_name) . "&lastname=" . urlencode($last_name) . "&website=" . urlencode($website) . "&hs_context=" . urlencode($hs_context_json);

//replace the values in this URL with your portal ID and your form GUID
$endpoint = 'https://forms.hubspot.com/uploads/form/v2/(my_portal_ID)/(My_GUID)';
$ch = @curl_init();
@curl_setopt($ch, CURLOPT_POST, true);
@curl_setopt($ch, CURLOPT_POSTFIELDS, $str_post);
@curl_setopt($ch, CURLOPT_URL, $endpoint);
@curl_setopt($ch, CURLOPT_HTTPHEADER, array('Content-Type: application/x-www-form-urlencoded'));
@curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
$response = @curl_exec($ch); //Log the response from HubSpot as needed.
@curl_close($ch);

0 Upvotes
Steve-a-reno
Participant

Failure to create submission in form

No resolution yet.
When I get one I'll post it.
I just find it odd that the data push fails from wordpress, yet works if I use the curl code as a form handler from a php form.
So I'm looking into making the wordpress use of curl to hubspot look like its coming from a browser.

0 Upvotes
Derek_Gervais
HubSpot Alumni
HubSpot Alumni

Failure to create submission in form

HI @Goran,

Are you still getting a 204? Was the form deleted from HubSpot? Can you give me a link to the page the form is on, and a link to the corresponding form in HubSpot so that I can take a closer look?

0 Upvotes
te74576
Member

Failure to create submission in form

@Derek_Gervais Any resolution to this issue? My team is experiencing something very similar. Let me know if you can help us out/what you need.

0 Upvotes
Steve-a-reno
Participant

Failure to create submission in form

Yes, I'm still getting a 204 reply and no errors in our logs.
I'm having to manually push the data using another page with a manual entry form.

The code for the cURL push is fired on the order completion page of our wordpress site.
We do a similar push on two other websites and it works just fine.

The code is part of an "Add_Action" on the functions page.
https://app.hubspot.com/forms-two/myid/myformid/

The code is fired after you complete the checkout of the shop.
https://www.mywebsite.com/checkout/

Part of the same code also dynamically adds sales amounts to other tracking codes for Google Analytics, so I can also see that that portion of the code is working as well.

Like I said, it was working up 8:44am on April 23.

Steve

0 Upvotes
Steve-a-reno
Participant

Failure to create submission in form

As of this morning I now get a 500 error from hubspot.
"Problem accessing /uploads/form/v2/myid/myformid"
"Server error while accepting form submission"

So now what?

0 Upvotes
Steve-a-reno
Participant

Failure to create submission in form

I should also add that a stand alone php page using the same code, to manually submit the sales data still works and gives me a 204 accepted response. All from the same domain name. So it's odd that the code passing data from wordpress fails but the same code being manually sent is accepted.
I also created a clone of the hubspot form and tried to get wordpress to submit to it, and got the same 500 error from the API

I filled out a Hubspot support ticket and was told that "Hubspot does not host or support the API" which again is an odd thing.

0 Upvotes