cancel
Showing results for 
Search instead for 
Did you mean: 
Data Governance
Join discussions on data governance practices, compliance, and security within the Databricks Community. Exchange strategies and insights to ensure data integrity and regulatory compliance.
cancel
Showing results for 
Search instead for 
Did you mean: 

Not able to get json response for "/api/2.0/accounts/{account_id}/metastores" endpoint.

nikhilkumawat
New Contributor III

Hi ,

I am trying to get list of all the metastores associated with an accountId. For this I am using the below REST API to get data:

accountId = json.loads(dbutils.notebook.entry_point.getDbutils().notebook().getContext().toJson())["tags"]["accountId"]
print(accountId)
url = 'https://accounts.cloud.databricks.com/api/2.0/accounts/{}/metastores'.format(accountId)
response = requests.get(url, auth=("<USERNAME>","<PASSWORD>"))
response.content

I have proper admin access and the response I get here is an HTML response, not a JSON one.

metastore_response 

Just to verify I also tried to use "Workspace" API like below:

accountId = json.loads(dbutils.notebook.entry_point.getDbutils().notebook().getContext().toJson())["tags"]["accountId"]
print(accountId)
url = 'https://accounts.cloud.databricks.com/api/2.0/accounts/{}/workspaces'.format(accountId)
response = requests.get(url, auth=("<USERNAME>","<PASSWORD>"))
response.content

This gives a proper JSON response.

So can someone help in what am I doing wrong while hitting "Metastore" endpoint ? And how to get proper JSON response out of it ?

1 ACCEPTED SOLUTION

Accepted Solutions

ruben1
New Contributor III

Apparently, it is working if I add the header `X-Databricks-Account-Console-API-Version` with value `2.0` to the call

View solution in original post

2 REPLIES 2

ruben1
New Contributor III

I'm having exactly the same problem. Seems a bug in the API.

ruben1
New Contributor III

Apparently, it is working if I add the header `X-Databricks-Account-Console-API-Version` with value `2.0` to the call

Join 100K+ Data Experts: Register Now & Grow with Us!

Excited to expand your horizons with us? Click here to Register and begin your journey to success!

Already a member? Login and join your local regional user group! If there isn’t one near you, fill out this form and we’ll create one for you to join!