Databricks - workspace import file api caused a file already exists exception

359 Views Asked by At

I'm working on Databricks API that upload a notebook file from local with following api call

enter image description here

In normal behavior this code work just fine. There are some cased that if test.py already in the workspace but with different a language property e.g. SQL. API will throw this exception

{"error_code":"RESOURCE_ALREADY_EXISTS","message":"Path (/Shared/Notebooks/test.py) already exists"

I'm assumed that the "overwrite" should mean to allow any overwrite of duplication file. Have any one experience similar problem?

1

There are 1 best solutions below

0
Naveen Sharma On BEST ANSWER

As @Alex Ott suggested in comments Posting it as an answer to help other community members.

As per this updated documentation

Use overwrite as a Boolean type, not as a string. it will specify whether to overwrite existing object or not.

"overwrite": true

here is request sample:

{
  "path": "string",
  "format": "SOURCE",
  "language": "PYTHON",
  "content": "string",
  "overwrite": true
}