How to query CASB API Successfully
search cancel

How to query CASB API Successfully


Article ID: 245108


Updated On:


CASB Gateway Advanced



The customer is trying to query the API for information however the request are failing with "Authorization Required" error. 


This may not necessarily be an authentication issue, the API calls have a number of mandatory requirements...

The most common issue we see is that a header is missing, the below code snippet is a good example of how the call should be peformed.
import json
conn = http.client.HTTPSConnection("")
payload = ''
headers = {
  'Content-Type': 'application/json',
  'X-Elastica-Dbname-Resolved': 'True',
  'Authorization': 'Basic YzU1ZjNiMDg2MzBhMTFlYzgyNWVjZTQ5MjVlYzRmZGE6a1RhZ1ZWaEdESUlVbm5aY0lBbkt2aU5zNEI4a0VkcXFIUGVoRzFnSDl1bw=='
conn.request("GET", "/mytenantname/audit/v2/data/?resource=service&earliest_date=1638349200&latest_date=1640077200&resolution=31556926&brr=80,85", payload, headers)
res = conn.getresponse()
data =
The basic auth is an amalgamation of the user and secret strings.

As per the above the X header and the Content-Type headers are both mandatory, see the link below for more detail and how you can perform initial testing with the postman tool.
Also check out the links below which detail the requirement for the X header and the basic request format….
If customers continue to run into problems they are advised to use postman or curl to perform some basic tests and once successful with those transcribe the approach into the required code.