- Access exclusive content
- Connect with peers
- Share your expertise
- Find support resources
04-21-2021 06:55 AM
Hello,
I am getting the below error when sending the POST request to "https://api.prismacloud.io/search/config",
Error:
{
"errorMessage": "Expecting value: line 1 column 1 (char 0)",
"errorType": "JSONDecodeError",
"stackTrace": [
" File \"/var/task/lambda_function.py\", line 49, in lambda_handler\n queryRQL(REQ_HEADER,url,requestbodyAWS)\n",
" File \"/var/task/lambda_function.py\", line 14, in queryRQL\n json_string = json.dumps(response.json())\n",
" File \"/opt/python/requests/models.py\", line 900, in json\n return complexjson.loads(self.text, **kwargs)\n",
" File \"/var/lang/lib/python3.8/json/__init__.py\", line 357, in loads\n return _default_decoder.decode(s)\n",
" File \"/var/lang/lib/python3.8/json/decoder.py\", line 337, in decode\n obj, end = self.raw_decode(s, idx=_w(s, 0).end())\n",
" File \"/var/lang/lib/python3.8/json/decoder.py\", line 355, in raw_decode\n raise JSONDecodeError(\"Expecting value\", s, err.value) from None\n"
]
}
Here is my python code:
import requests
import json
import csv
import re
import sys
Query_ACM = "{\"timeRange\":{\"value\":{\"unit\":\"hour\",\"amount\":24},\"type\":\"relative\"},\"withResourceJson\":true,\"query\":\"config from cloud.resource where cloud.type = 'aws' AND api.name = 'aws-acm-describe-certificate'\"}"
def login():
header = {'Content-Type':'application/json'}
payload = {"username":"AccessKey","password":"SecretAccessKey"}
API = "https://api.prismacloud.io"
response = requests.request('POST', '{}/login'.format(API), json=payload, headers=header)
json_response = response.json()
return json_response['token']
JWT_TOKEN = login()
url = "https://api.prismacloud.io/search/config"
REQ_HEADER = {'Content-Type':'application/json','x-redlock-auth':JWT_TOKEN}
def queryRQL(REQ_HEADER,url,RQLquery):
response = requests.request("POST", url, data=RQLquery, headers=REQ_HEADER)
json_string = json.dumps(response.json())
json_data = json.loads(json_string)
return json_data
json_output = queryRQL(REQ_HEADER,url,Query_ACM)
08-12-2022 07:24 AM
Greetings PPrabhakar,
I hope that this note finds you well! I know that it has been a while since you had posted this question but I wanted to see if you still potentially needed any help. Thank you for your time and I hope that you have a good remainder of your day.
Kind Regards,
J. Avery King
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!