Getting error "HTTP Status 405 - Method Not Allowed" when making REST API call
search cancel

Getting error "HTTP Status 405 - Method Not Allowed" when making REST API call

book

Article ID: 404114

calendar_today

Updated On:

Products

VCF Operations/Automation (formerly VMware Aria Suite)

Issue/Introduction

1. You have customized your PowerShell script and are trying to acquire the token through the script. You are getting the error "Attempting to log into [RESTendpoint.example.com] with admin."

2. You are getting the error "HTTP Status 405 - Method Not Allowed" when trying to acquire the token directly through the URL https://RESTendpoint.example.com/suite-api/api/auth/token/acquire.

Environment

Aria Operations 8.18.x

Cause

 Incorrect PowerShell script.

Resolution

Important Note: Custom script in PowerShell is out of Broadcom Global Support's break/fix scope. The purpose of this KB is to provide some guidance. The users will need to reach out to their account team if further assistance is needed regarding the PowerShell script.

1. Make sure the API is working in the following fields through https://AriaOperationsNode_IP_or FQDN/suite-api/doc/swagger-ui.html.

    (1) Click on Authorize on the top right and type in the local user admin credentials.

    (2) Search for auth/token/acquire in the search bar and locate POST /api/auth/token/acquire as shown in the screenshot below:

 

  (3) Click on Try it out to the right, and put in the information in the userPassword field as shown in the following screenshot, then click Execute.

 

 

(4) Make sure you get the following 200 response, and you can see the token in the Response body.

 

 

The above confirms that the Aria Operations API is working as documented in VMware Aria Operations 8.18 - Acquire an Authentication Token.

If the above is not working, please contact Broadcom Global Support.

 

2. In the PowerShell script, run the following script should also provide the token:


$vrops = "RESTendpoint.example.com"
$headers = @{ "Content-Type" = "application/json"; "Accept" = "application/json" }
$body = @{ "username" = "admin"; "password" = "######"; "authSource" = "Local" }
$jsonbody = $body | ConvertTo-Json
$url = "https://$vrops/suite-api/api/auth/token/acquire"
$response = Invoke-WebRequest -Uri $url -Headers $headers -Body $jsonbody -Method Post
$response

Note: Replace the above "######" with the admin password.