Prisma Insights API in PowerShell

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements

Prisma Insights API in PowerShell

L0 Member

Hi all - I am looking for some help. I have been asked if I can extract data using the Prisma Insights API, I have used PowerShell for this in the past for a similar thing in AppDynamics so I think it would be a good starting point for this work.

 

I have managed to get the access token and use this in the next part of the code to make the API call but I am getting the following error:

 

Invoke-RestMethod : {"errorCode":"REST10001","message":"Unexpected server error","details":"Failed to process request"}

 

Has anyone used PowerShell with the API or come across this error ?

 

Any advise appreciated.

1 accepted solution

Accepted Solutions

Hi - I managed to get past the error message. The issue was that PS was not accepting the JSON payload in directly in the code. I put it in a text file and read it in to the script - this solved the issue. 

Thanks for responding though.

View solution in original post

3 REPLIES 3

L3 Networker

StephenBuist, I need a little more context in regards to what you mean by Prisma Insights API.  Please use the below links to start or send me a link to the product you are referring to.

 

Prisma Access Insights APIs 

Access an API with powershell 

Hi - I managed to get past the error message. The issue was that PS was not accepting the JSON payload in directly in the code. I put it in a text file and read it in to the script - this solved the issue. 

Thanks for responding though.

Hi Stephen,

 

I am trying to achieve somewhat the same, but using curl. Can you please give an example of the command line, which you used to get the data? I am stuck at the same issue, as you were. Here is my curl command, that I am using. I have put the payload in a .josn file and load it in the command:

 

curl -X POST https://pa-staging02.api.prismaaccess.com/api/sase/v2.0/resource/query/tunnel_status -H "Authorization: Bearer eyJ0eXAiOiJKV1QiLCJraWQiOiJyc2Etc2lnbi1wa2NzMS0yMDQ4LXNoYTI1Ni8xIiwiYWxnIjoiUlMyNTYifQ.eyJzdWIiOiJmMGU1NjQzMi1iODkxLTRiOTItYWZmNS0xOWI5YTc3YmY0NGQiLCJjdHMiOiJPQVVUSDJfU1RBVEVMRVNTX0dSQU5UIiwiYXVkaXRUcmFja2luZ0lkIjoiOWJkMGQ1ODgtNDU4OC00ZTI0LWIxNDktNDA1YjAxNTY4YzY0LTEyNjc4OTE5Iiwic3VibmFtZSI6ImYwZTU2NDMyLWI4OTEtNGI5Mi1hZmY1LTE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-Tenant:1547011937" -H "Content-Type: application/json" --data-binary @c:\temp\input.json >c:\temp\output.json
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 666 100 99 100 567 138 791 --:--:-- --:--:-- --:--:-- 936

Below is the output, which I put in the output.json file:
{"errorCode":"REST10001","message":"Unexpected server error","details":"Failed to process request"}




Do I understand correctly, that instead of .json file, you use .txt? How do you feed the .txt in the command? Or are you saying, that you tried putting the .json load directly in the command, and then did that as me, putting it in a .json file? Your help will be much appreciated. 

 

Kind Regards,

KPopov

  • 1 accepted solution
  • 2682 Views
  • 3 replies
  • 1 Likes
Like what you see?

Show your appreciation!

Click Like if a post is helpful to you or if you just want to show your support.

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!