cancel
Showing results for 
Search instead for 
Did you mean: 
Data Governance
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

Welcome to Databricks Community: Lets learn, network and celebrate together

Join our fast-growing data practitioner and expert community of 80K+ members, ready to discover, help and collaborate together while making meaningful connections. 

Click here to register and join today! 

Engage in exciting technical discussions, join a group with your peers and meet our Featured Members.