2

I did try to send the curl request to HUBSPOT using the following endpoint "https://forms.hubspot.com/uploads/form/v2/{portalId}/{formGuid}". {portalId} and {formGuid} was replaced correctly.

When the request is sent the status code 204 is returned as a response but there is no data added.

The codebase on the server and on my localhost is exactly the same. It is working just fine on my localhost but not working on the server.

Please can anybody help to determine the issue as not able to figure out the possible reasons for this? There are many questions regarding the same.

Thanks in advance.

Function for api call.

public static function api($post_values)
    {
        self::getKeyValues();
        //replace the values in this URL with your portal ID and your form GUID
        $endpoint = 'https://forms.hubspot.com/uploads/form/v2/{portalId}/{formGuid}';
        $endpoint = str_replace("{portalId}", self::$portalID, $endpoint);
        $endpoint = str_replace("{formGuid}", self::$formID, $endpoint);
        $ch = @curl_init();
        @curl_setopt($ch, CURLOPT_POST, true);
        @curl_setopt($ch, CURLOPT_POSTFIELDS, $post_values);
        @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);
    @curl_setopt($ch, CURLOPT_SSL_VERIFYHOST, 0);
    @curl_setopt($ch, CURLOPT_SSL_VERIFYPEER, 0);

        $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);
        return $status_code;  //if 204 status code is printed that means for has been submitted successfully.
    }
  • What you mean by `not working on the server`? Is it show error, or timed out or anything? I recommend you to replace `@` sign before `curl_exec` and other functions as it suppress error - so you don't see any relevant error that could help you to understand the problem. – krylov123 Dec 25 '20 at 15:03
  • @krylov123, I have removed @ sign before curl_exec and I added a breaking point to view the response from Hubspot. The returned response is '204' and no error is shown which helps me understand what is the problem. But the email I added in the Hubspot to create a contact did not reflect in the Hubspot. No contact was created there. Hope this makes more sense, let me know if you need more information on this. – Suyash Ranawat Jan 03 '21 at 20:16
  • So, you get 204 response in both cases - success and failed? If so, then there is no way you can determine the error on your side and you should contact hubspot support with that results. – krylov123 Jan 05 '21 at 15:50
  • Thanks, @krylov123 I'll try to do that. – Suyash Ranawat Jan 15 '21 at 15:10

0 Answers0