Adding slash ( / ) with single quote '


#1

When we are submitting the form using the Form API of hubspot and then it is submitting the values. But when we use some special characters then the values are not entering properly.

For example: In the form on some text field we have written as "it's simple", but in the form submission of Hubspot it is showing like "it's simple"(backword slash is adding before single quote).
Please find the below screenshot for clear explanation of the issue.

Can you please help us in resolving this issue.

Thank you.


#2

Hi @shradha,

I'm not able to reproduce this in my own portal. Can you give me an example request you're making to the Forms API? Is it possible that these quotes are being escaped improperly in whatever language you're using to submit to the Forms API?


#3

Hi @Derek_Gervais

The following is the requesting code for the Hubspot API Forms.

$str_post = "event_name=" . $_POST['event_name']
. "&category=" . $fullcatname
. "&venue=" . $_POST['venue']
. "&venue_address_stree1=" . $_POST['venue_address_stree1']
. "&venue_address_stree2=" . $_POST['venue_address_stree2']
. "&city=" . $_POST['city']
. "&state=" . $_POST['state']
. "&zip=" . $_POST['zip']
. "&country=" . $_POST['country']
. "&start_date=" . $_POST['start_date']
. "&end_date=" . $_POST['end_date']
. "&time_from=" . $_POST['time_from']
. "&time_until=" . $_POST['time_until']
. "&event_info=" . $_POST['event_info']
. "&multiple_event_info=" . $_POST['multiple_event_info']
. "&email=" . $_POST['submitter_email']
. "&firstname=" . $_POST['submitter_s_name']
. "&lastname=" . $_POST['lastname']
. "&submitter_s_phone_area_code=" . $_POST['submitter_s_phone_area_code']
. "&phone=" . $_POST['phone']
. "&info_phone_area_code=" . $_POST['info_phone_area_code']
. "&info_phone_number=" . $_POST['info_phone_number']
. "&website=" . $_POST['website']
. "&event_information_email=" . $_POST['event_information_email']
. "&image=" . $_POST['image'];
//Leave this one be

    //replace the values in this URL with your portal ID and your form GUID
    $endpoint = 'https://forms.hubspot.com/uploads/form/v2/1746707/359b0079-a688-4e12-84db-74e2b4e5231a';
     
    $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.
    $status_code = @curl_getinfo($ch, CURLINFO_HTTP_CODE); //Log the response status code
    @curl_close($ch)

Hope this may help you in finding the solution.


#4

Hi @shradha,

I actually can't get as much information from a code snippet like this, since I don't have any insight into the value of those variables and I can't log the final result to see what the actual request would look like. Can you try logging the full string you end up with? I think it's likely that there are single quotes being escaped with a slash in some of your strings, and they're somehow being included in the final request.