Abdul Haseeb
Abdul Haseeb

Reputation: 512

Using DataBricks API 2.0 with Tokens

I'm trying to hit DataBricks API 2.0 using Bearer Tokens and I'm getting 200 response but results are not showing.

This is the Response I'm receiving

I'm running this command,

curl -H @{'Authorization' = 'Bearer <Token Here>'} https://DataBricks Instance Here/api/2.0/clusters/list

Upvotes: 0

Views: 2578

Answers (2)

anoj-cha
anoj-cha

Reputation: 281

I had a similar problem before. I was getting a 200 response code and the same response saying 'Sign In' in HTML. Looks like I had a token from a different workspace. Interestingly, a token from a different workspace got me a 200 response instead of a 401 which made me believe I had the right token.

when I had a similar issue as yours..

For your issue, first off, I'd suggest using POSTMAN to help you isolate the issue. This way you wouldn't have to worry about the syntax.

Then you can get POSTMAN to create the CURL request. Like the one you see in screenshot below. I'm adding '|jq ''' at the end simply to pretty-print the output (can be ignored).

working POSTMAN call

curl --location --request GET 'https://adb-1XXXXXXXXX.1.azuredatabricks.net/api/2.0/dbfs/list?path=/' \
> --header 'Authorization: Bearer dapifxxxxxxxxxxxxxx' \
> --header 'Content-Type: application/json' | jq '' 

Upvotes: 1

CHEEKATLAPRADEEP
CHEEKATLAPRADEEP

Reputation: 12768

Try this below curl command to get the list of clusters:

curl -X GET -H "Authorization: Bearer <Token Here>" "https://< DataBricks Instance Here>/api/2.0/clusters/list"

enter image description here

Upvotes: 1

Related Questions