cancel
Showing results for 
Search instead for 
Did you mean: 
Data Engineering
Join discussions on data engineering best practices, architectures, and optimization strategies within the Databricks Community. Exchange insights and solutions with fellow data engineers.
cancel
Showing results for 
Search instead for 
Did you mean: 

Databricks Rest API

Ramya
New Contributor III

Hi, I am having an issue accessing data bricks API 2.0/workspace/mkdirs through python. I am using the below azure method to generate the access token. I am not sure why I am getting 404 any suggestions?

token_credential = DefaultAzureCredential()

scope = "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default".

Below is the snippet of my code.

response = requests.post(

 url="https://databricksurl/api/2.0/workspace/mkdir",

 headers={ 'Authorization': "Bearer " + access_token,

      'Accept': 'application/json'},

 json = {'path' : '/user/test'}

)

print(json.dumps(json.loads(response.text), indent = 2))

print(response)

Error:

{

 "error_code": "ENDPOINT_NOT_FOUND",

 "message": "No API found for 'POST /workspace/mkdir'"

}

1 ACCEPTED SOLUTION

Accepted Solutions

Just a friendly follow-up. Did any of the responses help you to resolve your question? if it did, please mark it as best. Otherwise, please let us know if you still need help.

View solution in original post

4 REPLIES 4

Ramya
New Contributor III

@Kaniz Fatma​ I checked that community thread and it didn't help. I am using https://docs.microsoft.com/en-us/azure/databricks/dev-tools/api/latest/aad/app-aad-token to create an access token through that I am trying to access this 2.0/workspace/mkdir to create a folder in data bricks which is not working. Any suggestions?

Thanks

PCR
New Contributor II

issue is with data/json...

try the below -

from azure.identity import DefaultAzureCredential

import requests

default_scope = "2ff814a6-3304-4ab8-85cb-cd0e6f879c1d/.default"

credential = DefaultAzureCredential()

token = credential.get_token(default_scope)

access_token = str(token.token)

url="https://adb-xxxxx.azuredatabricks.net/api/2.0/workspace/mkdirs"

headers={"Authorization":"Bearer "+access_token, "Content-Type": "application/x-www-form-urlencoded"}

response = requests.post(

 url=url,

 headers=headers,

 data = '{"path":"/dpaas-ids2/test"}'

)

print(response)

Ramya
New Contributor III

Yes that is correct!. It worked. Thanks

Just a friendly follow-up. Did any of the responses help you to resolve your question? if it did, please mark it as best. Otherwise, please let us know if you still need help.

Connect with Databricks Users in Your Area

Join a Regional User Group to connect with local Databricks users. Events will be happening in your city, and you won’t want to miss the chance to attend and share knowledge.

If there isn’t a group near you, start one and help create a community that brings people together.

Request a New Group