cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
What’s new: end-to-end encryption, Replay and Dash updates. Find out more about these updates, new features and more here.

Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 

API delete by id:# via CURL

API delete by id:# via CURL

Wookiee
Explorer | Level 4

In one script in my FileMaker database solution, I upload a file to a constructed path, then save the unique id:xxxxxxxxxxxxxxxx number for that record, to tie the record to the file in the DropBox directory.

 

In another script, I wanted to delete the file by id:xxxxxxxxxxxxx and not by path. If I understand pathString(pattern="(/(.|[\r\n])*)|(ns:[0-9]+(/.*)?)|(id:.*)") correctly, I should be able to do this, no?

 

 

curl -X POST https://api.dropboxapi.com/2/files/delete_v2 \
    --header "Authorization: Bearer <get access token>" \
    --header "Content-Type: application/json" \
    --data "{\"path\":\"$idDBX"}"

//where $idDBX is the stored value of id:xxxxxxxxxxxxx

 

The result I get returned is "Error in call to API function "files/delete:2": Unexpected HTTP headers: "Dropbox-Api-Arg""

 

1 Accepted Solution

Accepted Solutions

Здравко
Legendary | Level 20

@Wookiee, The question of mine was rhetoric! I hoped it'll direct you. Ok... can you see the difference of your 2 posts and figure out alone what's different and wrong or...?

 

PS: Everywhere some path can be used, the equivalent id can be used too. Even more a hybrid form may be used too: id of a folder followed by a relative path. In all cases that's NOT the issue (I assume the id is correct).

View solution in original post

6 Replies 6

Здравко
Legendary | Level 20

Hi @Wookiee,

Are you sure, you have executed exactly that curl command you posted and not something else? 🤔 Why do I ask? The error message states that you have passed "Dropbox-Api-Arg" header, but it's missing on your post! 😉😀

Hope this helps.

Wookiee
Explorer | Level 4

I just took the code section from the dev API example... here are the args that is getting sent by FileMaker using it's "Insert from URL" script step:

-X POST
 --header "Content-Type: application/json"
 --header "Authorization: Bearer <redacted>"
 --header "Dropbox-API-Arg: {\"path\":\"id:m5ktIrz8BXoAAAAbAAAASg\"}"
--dump-header

 

Здравко
Legendary | Level 20

@Wookiee, The question of mine was rhetoric! I hoped it'll direct you. Ok... can you see the difference of your 2 posts and figure out alone what's different and wrong or...?

 

PS: Everywhere some path can be used, the equivalent id can be used too. Even more a hybrid form may be used too: id of a folder followed by a relative path. In all cases that's NOT the issue (I assume the id is correct).

Wookiee
Explorer | Level 4

Not quite there yet, but you have me on the right path, I think...

data-data-data-rdj.gif

iNeil
Dropbox Engineer

Hello @Wookiee,

The error "Unexpected HTTP headers: 'Dropbox-Api-Arg'" indicates that the HTTP request you sent includes a header that the server is not expecting or does not recognize, as mentioned by Здравко. For example, --header "Dropbox-API-Arg: {\"path\":\"id:m5ktIrz8BXoAAAAbAAAASg\"}".

Please note that the /2/files/upload and /2/files/delete_v2 endpoints have different formats when including parameters. The /2/files/upload endpoint uses the header "Dropbox-API-Arg," while the /2/files/delete_v2 endpoint uses the request body data. Below is an example of how to implement the /2/files/delete_v2 endpoint using the request body data via cURL.

 

curl -X POST \
--header "Authorization: Bearer " \
--header "Content-Type: application/json" \
--data "{\"path\":\"id:m5ktIrz8BXoAAAAbAAAASg\"}" \
https://api.dropboxapi.com/2/files/delete_v2

 

Wookiee
Explorer | Level 4

Thank you both! The following worked perfectly in FileMaker to delete the file. Putting this here for anyone who might need it.

"-X POST" & ¶ &
" --header \"Content-Type: application/json\"" & ¶ &
" --header \"Authorization: Bearer " & $authToken & "\"" & ¶ &
" --data \"" & $dropboxArgJSON & "\"" & ¶ &
"--dump-header $responseHeaders"

 

Need more support?
Who's talking

Top contributors to this post

  • User avatar
    Wookiee Explorer | Level 4
  • User avatar
    iNeil Dropbox Engineer
  • User avatar
    Здравко Legendary | Level 20
What do Dropbox user levels mean?