I have a powershell script that sends a room notification that has been working for quite some time that just started failing with a 405 method not allowed error after our upgrade from 2.2.3 to 2.2.6. Here is the powershell:
#
# Send HipChat room notification of reboots
#
#Variables for the json post
$APIKey = '<ourapikey>'
#The key is tied to user who requests it and will post as that person (may want to build an admin user)
$Room = '63' #Case sensitive if using name!! Use ID from the room it's easier
#Hipchat post url variable
$apiuri = "http://<ourhipchatserver>/v2/room/$Room/notification?auth_token=$APIKey”
#Notify defaults to false, change to true for notifications
$body = @{
color = “red”;
message= “REBOOTS IN PROGRESS: STAGE Load Controller and Generators”;
notify= “true”;
message_format= “text”
}
#Post to room
Invoke-RestMethod -Method Post -Uri $apiuri -body (ConvertTo-Json $body) -ContentType “application/json”
#End of Hipchat Post
Here is the error from powershell, which is reflected in the hipchat log:
Invoke-RestMethod : The remote server returned an error: (405) Method Not Allowed.
Any ideas why this might be happening?
Hi Parker,
I hope you're doing well. Can you try the following cURL command (substitute your FQDN, API_V2_TOKEN, ROOM_ID and MESSAGE values for the placeholders) and let me know if it's successful?
curl -d '{"color": "red", "message": "<MESSAGE>", "notify": true, "message_format": "text"}' -H 'Content-Type: application/json' 'https://<FQDN>/v2/room/<ROOM_ID>/notification?auth_token=<API_V2_TOKEN>'
Additionally, whenever I was testing, I noticed that if I used _http_ instead of _https_ for the URL, I would always get an NGINX error 301 HTTP in HCS v2.2.6 due to the fact that port 80 automatically redirects to _https_ by default. I'm unsure if Powershell handles this error in a different way, so it's worth noting.
Lastly, log into the HipChat Server command line and tail the /var/log/hipchat/coral.log as this is the service that controls the external API. I'm wondering if there are any further errors logged here as it might provide additional clues.
Cheers,
-David
HipChat Server/DataCenter Support Engineer | Atlassian
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.