- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
08-18-2019 11:11 PM - last edited on 09-02-2020 10:18 AM by kwadsack
Hi,
I'm trying to run a config search using the API. I can successfully get the JWT token and can use the token to do basic get options.
However, when trying the configuration search I get a 401 unauthorized error if I format the data as json( using header1). And if I don't specify the Content-Type, then I get a 500 internal server error ( header2). Just wondering if someone might be able to help with identifying the issue.
Python code snippet:
URL = 'https://api.prismacloud.io/search/config' header1 = {"Content-Type":"application/json", "Accept": "text/csv", "x-redlock-auth":jwt} header2 = {"Accept":"text/csv", "x-redlock-auth":jwt} requestbody = { "query": "config where cloud.account = 'Name of cloud account' AND api.name = "azure-storage-account-list'", "timeRange": { "type": "relative", "value": { "unit": "hour", "amount": 24 } } }
.....
response=request.requests('POST', URL, json=requestbody, header=header1)
08-19-2019 07:59 AM
I don't see anything wrong with header1 (header 2 is missing the content-type so that would throw the 500 as expected). If you are getting a 401, then the token has expired. FYI, there is a syntax issue with your "query" line - you have an open single quote.
08-19-2019 07:59 AM
I don't see anything wrong with header1 (header 2 is missing the content-type so that would throw the 500 as expected). If you are getting a 401, then the token has expired. FYI, there is a syntax issue with your "query" line - you have an open single quote.
08-19-2019 04:43 PM
Thanks. I don't think the token expired since I can use the same token to do other API calls such as a health check.
Thanks for pointing out open single quote. A copy paste error on my end :).
"query": "config where cloud.account = 'Name of cloud account' AND api.name = 'azure-storage-account-list'", "timeRange": { "type": "relative", "value": { "unit": "hour", "amount": 24 } } }
08-19-2019 05:12 PM
So it might be an issue with the token, since the health check doesn't need a token. Thanks for the response.
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!