06-07-2022 09:31 AM
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'"
}
07-29-2022 11:14 AM
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.
06-08-2022 08:47 AM
@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
06-10-2022 03:50 PM
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)
06-13-2022 03:19 PM
Yes that is correct!. It worked. Thanks
07-29-2022 11:14 AM
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.
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