403 Error From External Post to Forms API


#1

Getting 403 error posting to the forms api from our new website thats in development. Worked fine the first 4 times. Is there a work-around for this?

I noticed in another post that there might be an issue if the website is on an “IP address” versus a real domain name. That is the case with ours however it worked the first 4 times?

Any ideas?

You don’t have permission to access “http://forms.hubspot.com/uploads/form/v2/1668259/5f089d3f-771f-4bfb-9321-b32463d51920” on this server.


Reference #18.17dc6068.1492711640.1ec5b9f


403 response from Forms API
#2

@davidatslice can you post your call and the raw response from HubSpot?


#3

The Call

2017-04-19 15:00:17.274360 - DEBUG --> gform_after_submission: hubspot_post_url => https://forms.hubspot.com/uploads/form/v2/1668259/5f089d3f-771f-4bfb-9321-b32463d51920
2017-04-19 15:00:17.274379 - DEBUG --> gform_after_submission: body => Array
(
[firstname] => abc
[lastname] => def
[email] => dmayerlen@yahoo.com12
[pageName] =>
[pageURL] => http://34.207.128.10/test-gravity/
[state] => Texas
)

*** The Response ***

2017-04-19 15:00:17.350014 - DEBUG --> gform_after_submission: response => Array
(
[headers] => Requests_Utility_CaseInsensitiveDictionary Object
(
[data:protected] => Array
(
[server] => AkamaiGHost
[mime-version] => 1.0
[content-type] => text/html
[content-length] => 358
[expires] => Wed, 19 Apr 2017 19:00:17 GMT
[cache-control] => max-age=0, no-cache, no-store
[pragma] => no-cache
[date] => Wed, 19 Apr 2017 19:00:17 GMT
)

    )

[body] => <HTML><HEAD>
Access Denied

Access Denied

You don’t have permission to access “http://forms.hubspot.com/uploads/form/v2/1668259/5f089d3f-771f-4bfb-9321-b32463d51920” on this server.


Reference #18.3d6533b8.1492628417.c7e05c1

[response] => Array
    (
        [code] => 403
        [message] => Forbidden
    )

[cookies] => Array
    (
    )

[filename] => 
[http_response] => WP_HTTP_Requests_Response Object
    (
        [response:protected] => Requests_Response Object
            (
                [body] => <HTML><HEAD>
Access Denied

Access Denied

You don’t have permission to access “http://forms.hubspot.com/uploads/form/v2/1668259/5f089d3f-771f-4bfb-9321-b32463d51920” on this server.


Reference #18.3d6533b8.1492628417.c7e05c1

                [raw] => HTTP/1.1 403 Forbidden

Server: AkamaiGHost
Mime-Version: 1.0
Content-Type: text/html
Content-Length: 358
Expires: Wed, 19 Apr 2017 19:00:17 GMT
Cache-Control: max-age=0, no-cache, no-store
Pragma: no-cache
Date: Wed, 19 Apr 2017 19:00:17 GMT
Connection: close

Access Denied

Access Denied

You don’t have permission to access “http://forms.hubspot.com/uploads/form/v2/1668259/5f089d3f-771f-4bfb-9321-b32463d51920” on this server.


Reference #18.3d6533b8.1492628417.c7e05c1

                [headers] => Requests_Response_Headers Object
                    (
                        [data:protected] => Array
                            (
                                [server] => Array
                                    (
                                        [0] => AkamaiGHost
                                    )

                                [mime-version] => Array
                                    (
                                        [0] => 1.0
                                    )

                                [content-type] => Array
                                    (
                                        [0] => text/html
                                    )

                                [content-length] => Array
                                    (
                                        [0] => 358
                                    )

                                [expires] => Array
                                    (
                                        [0] => Wed, 19 Apr 2017 19:00:17 GMT
                                    )

                                [cache-control] => Array
                                    (
                                        [0] => max-age=0, no-cache, no-store
                                    )

                                [pragma] => Array
                                    (
                                        [0] => no-cache
                                    )

                                [date] => Array
                                    (
                                        [0] => Wed, 19 Apr 2017 19:00:17 GMT
                                    )

                            )

                    )

                [status_code] => 403
                [protocol_version] => 1.1
                [success] => 
                [redirects] => 0
                [url] => https://forms.hubspot.com/uploads/form/v2/1668259/5f089d3f-771f-4bfb-9321-b32463d51920
                [history] => Array
                    (
                    )

                [cookies] => Requests_Cookie_Jar Object
                    (
                        [cookies:protected] => Array
                            (
                            )

                    )

            )

        [filename:protected] => 
        [data] => 
        [headers] => 
        [status] => 
    )

)


#4

I’m not sure why you are getting an access denied but your string post body looks a little off from our documentation. I would take a look at here on how to format it.


#5

It works now. Not sure why it worked at first and …

Bottom line is it works. I looked back at the API as you suggested and noticed that I was not creating the hs_context variable correctly.

Thank you!!!


#6

@davidatslice perfect! i’m glad you have it working. Please feel free to let me know if you run into anything else.