0

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
Abdul Haseeb
  • 442
  • 4
  • 22

2 Answers2

1

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

CHEEKATLAPRADEEP
  • 12,191
  • 1
  • 19
  • 42
1

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 '' 
anoj-cha
  • 211
  • 5
  • 19
  • I tried running on POSTMAN and it's giving same issue with 200 response and Sign In HTML. – Abdul Haseeb Jan 08 '21 at 08:43
  • Ok that narrows down the issue then to Token. Would you like to try another token and ensure you are not copying across any spaces? Also if you attach a screenshot of POSTMAN, someone can verify you've got the right details (you may want to show the 'headers' section in particular but hide the token) – anoj-cha Jan 10 '21 at 01:18