import requests
DOMAIN = ws.deployment_url
TOKEN = dbutils.secrets.get(json_['workspace_pat_scope'], ws.ws_token)
print(json_['workspace_pat_scope'])
loggr.info(f"Looking for data_source_id for : {json_['sql_warehouse_id']}!")
response = requests.get(
'https://%s/api/2.0/preview/sql/data_sources' % (DOMAIN),
headers={'Authorization': 'Bearer %s' % TOKEN},
json=None,
timeout=60
)
print(response)
resources = json.loads(response.text)
found = False
for resource in resources:
if resource['endpoint_id'] == json_['sql_warehouse_id']:
data_source_id = resource['id']
loggr.info(f"Found data_source_id for : {json_['sql_warehouse_id']}!")
found = True
break
if (found == False๐
dbutils.notebook.exit("The configured SQL Warehouse Endpoint is not found.")
And when trying to run this code
import requests
DOMAIN = ws.deployment_url
TOKEN = dbutils.secrets.get(json_['workspace_pat_scope'], ws.ws_token)
print(json_['workspace_pat_scope'])
loggr.info(f"Looking for data_source_id for : {json_['sql_warehouse_id']}!")
response = requests.get(
'https://%s/api/2.0/preview/sql/data_sources' % (DOMAIN),
headers={'Authorization': 'Bearer %s' % TOKEN},
json=None,
timeout=60
)
print(response)
Getting a 403 error. That might be the problem. The token and api pair work ok when we tried to get a response in CLI not sure why its not working in databricks.