Has anyone used Powershell to interact with REST API on PA500?
When I use the Invoke-RestMethod cmdlet to try and generate a key, I get back an empty response. If I run the keygen through a browser, it successfully returns a key. Running 6.1.1.
PS C:> Invoke-RestMethod -Uri http://<ip-of-PA500>/api/?type=keygen%26ampuser=<adminuser>%26amppassword=<adminpassword>
Solved! Go to Solution.
$HostPA = "http://hostname"
[xml]$content = Invoke-WebRequest "$HostPA/api/?type=keygen&user=user-name&password=user-password"
$apiKey = $content.response.result.key
That worked...although I'm puzzled as to why Invoke-RestMethod did not.
I retried the same steps you listed but replaced Invoke-WebRequest with Invoke-RestMethod. It worked as well.
Essentially, applying the xml bracket and assigning the output of the command to a variable, let me pull out the relevant information. However, I wasn't expecting it to work that way. I had hoped the cmdlet would output the entire XML stream to the display and not need me to specify the specific data portions.
Click Accept as Solution to acknowledge that the answer to your question has been provided.
The button appears next to the replies on topics you’ve started. The member who gave the solution and all future visitors to this topic will appreciate it!
These simple actions take just seconds of your time, but go a long way in showing appreciation for community members and the Live Community as a whole!
The Live Community thanks you for your participation!