- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
03-20-2025 05:23 AM
I'm having an issue authenticating via RESTful API, PAN OS version 11.1
Using SOAP to fetch my API key, then storing it here
$header = @{
"X-PAN-KEY" = $apikey
}
Then Invoke-Restmethod like this
Invoke-RestMethod -Uri $newURI -Method get -ContentType "application/json" -Headers $header
URI is https://ip_address/restapi/v11.1/Device/VirtualSystems
error message
Invoke-RestMethod : {"code":7,"message":"Unauthorized","details":[{"@type":"CauseInfo","causes":[{"code":5,"module":"panui_auth","description":"Unauthorized"}]}]}
I don't have any trouble pulling that data when I use SOAP like this
/api?key=$apikey&type=op&cmd=<show><devices><connected></connected></devices></show>
04-01-2025 09:48 PM
Hello @BBagent ,
Based on the error message, is the account you are using has the rights on the REST API (for custom role)?
(you can try to set a new custom role with all the REST API set to allowed, then assigned to the account you are using for the API calls and check)
Olivier
PCSNE - CISSP
Best Effort contributor
Check out our PANCast Channel
Disclaimer : All messages are my personal ones and do not represent my company's view in any way.
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 LIVEcommunity as a whole!
The LIVEcommunity thanks you for your participation!