How to query CASB API Successfully
search cancel

How to query CASB API Successfully

book

Article ID: 245108

calendar_today

Updated On: 04-30-2025

Products

CASB Gateway Advanced CASB Security Advanced CASB Security Premium CASB Security Standard CASB Gateway

Issue/Introduction

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

Cause

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

Resolution

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 performed.


 
import json
conn = http.client.HTTPSConnection("api.eu.elastica.net")
payload = ''
headers = {
  'Content-Type': 'application/json',
  'X-Elastica-Dbname-Resolved': 'True',
  'Authorization': 'Basic ■■■■■■■■■■■■■■■■■■■■■'
}
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 = res.read()
print(data.decode("utf-8"))
 


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.
 

Additional Information

 see the link below for more detail and how you can perform initial testing with the postman tool.

401 unauthorized using API Keys with SIEM or the Cloudsoc API

 

Also check out the links below which detail the requirement for the X header and the basic request format….

Cloudsoc APIs - Authentication