Json Error when sending POST request to https://api.prismacloud.io/search/config

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Please sign in to see details of an important advisory in our Customer Advisories area.

Json Error when sending POST request to https://api.prismacloud.io/search/config

L0 Member

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)

 

 

 
Note: When this script is run locally it perfectly runs fine, but when deployed to a lambda function it gives the error mentioned in the beginning.
Can anyone suggest why the lambda function fails to run this?
 
Thanks & Regards,
Pavan
1 REPLY 1

L4 Transporter

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

J. Avery King | Prisma Cloud | Customer Success Engineer
  • 1983 Views
  • 1 replies
  • 0 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!