405 Method not allowed

SOLVE
Occasional Contributor

In the method that's failing i make a PUT request to  https://api.hubapi.com/companies/v2/companies/$id

I'm using the ryanwinchester/hubspot-php library version ~1.2. We dynamically create the properties for the request based on the information in our website. We save the company id in our website so when we update the company we already have the id.
I catch any errors and log them. The error i'm recieving is:

2019/09/18 08:34:05 [error] 29889#0: *49607 FastCGI sent in stderr: "PHP message: [HubspotHelper] CompanyUpdate HTTP/1.1 405 Method Not Allowed
Date: Wed, 18 Sep 2019 08:34:05 GMT
Content-Length: 0
Connection: keep-alive
Set-Cookie: __cfduid=d5d95d054a0e70b0248bffdaf7d09bf821568795645; expires=Thu, 17-Sep-20 08:34:05 GMT; path=/; domain=.

http://hubapi.com/

; HttpOnly
X-Trace: 2B1558743E7AE095E83EE3B5492BBD281888B7A21A000000000000000000
Allow: POST,GET,OPTIONS
Access-Control-Allow-Credentials: false
Strict-Transport-Security: max-age=31536000; includeSubDomains; preload
Expect-CT: max-age=604800, report-uri="

https://report-uri.cloudflare.com/cdn-cgi/beacon/expect-ct

"
Server: cloudflare
CF-RAY: 5181fa905e2135fa-LHR" while reading response header from upstream, client: 172.16.10.115, server: gr5-api.guestrevuapp.internal, request: "POST /api/v1/property HTTP/1.1", upstream: "fastcgi://unix:/var/run/php-fpm/www.sock:", host: "

my-api.guestrevuapp.com

", referrer: "

https://my.guestrevuapp.com/accountprofile/edit

"

I'm struggling to reproduce this error in my local. It only happens on our live server. 

Thank you in advance!

Reply
0 Upvotes
1 Accepted solution

Accepted Solutions
Occasional Contributor

The issue was with the library.

Reply
0 Upvotes
3 Replies 3
Highlighted
HubSpot Moderator

Hi @DaganRead,

 

Do you have the request URL from that error log? I know you said you're making a PUT to https://api.hubapi.com/companies/v2/companies/{$id}, but do you have an example URL for one of your requests? It should be possible to make a PUT request to that endpoint (https://developers.hubspot.com/docs/methods/companies/update_company), so I wonder if your request is just going somewhere else that doesn't allow a PUT request. You could also try creating an issue for it here: https://github.com/ryanwinchester/hubspot-php/issues. It seems like other people have posted questions specific to that API client as issues; maybe someone else has come across this. But if you have an example request URL, I'm happy to look a little closer at what's going on here, because you shouldn't be getting a 405 to that endpoint.

 

 

Leland Scanlan

HubSpot Developer Support
Reply
0 Upvotes
Occasional Contributor

The request is generated by the library. I have an example of the request that is being generated. Unfortunetly i can't seem to reproduce the error on my local. And i don't capture the request information in our live server.
[19-Sep-2019 06:42:10 UTC] put

[19-Sep-2019 06:42:10 UTC] https://api.hubapi.com/companies/v2/companies/148117427?hapikey=xxx

[19-Sep-2019 06:42:10 UTC] Array
(
[json] => Array
(
[properties] => Array
(
[0] => stdClass Object
(
[name] => name
[value] => The Langdon
)

[1] => stdClass Object
(
[name] => v5_account_id
[value] => -1001-The Langdon
)

[2] => stdClass Object
(
[name] => tripadvisor_account_id
[value] => 6401202
)

[3] => stdClass Object
(
[name] => property_type
[value] => Accommodation Provider
)

[4] => stdClass Object
(
[name] => country
[value] => ZA
)

[5] => stdClass Object
(
[name] => phone
[value] => +44 800 133 7023
)

[6] => stdClass Object
(
[name] => website
[value] => www.guestrevu.com
)

[7] => stdClass Object
(
[name] => domain
[value] => guestrevu.com
)

[8] => stdClass Object
(
[name] => existing_solution
[value] => GuestRevu V5
)

[9] => stdClass Object
(
[name] => rooms
[value] => 14
)

)

)

[headers] => Array
(
[User-Agent] => SevenShores_Hubspot_PHP/1.0.0-rc.1 (https://github.com/ryanwinchester/hubspot-php)
)

)

Reply
0 Upvotes
Occasional Contributor

The issue was with the library.

Reply
0 Upvotes