当前位置: 动力学知识库 > 问答 > 编程问答 >

ubuntu - Dropbox API v2 /delete

问题描述:

I'm learning about Dropbox API v2, testing the commands and etc to practice.

When I tried type the delete command( https://www.dropbox.com/developers/documentation/http/documentation#files-delete):

curl -X POST https://api.dropboxapi.com/2/files/delete \

--header 'Authorization: Bearer *****token******' \

--header 'Content-Type: application/json' \

--data '{"path":"*/Dropbox/home/douglas/uploader2*"}'

the output returns:

Error in call to API function "files/delete": request body: could not decode input as JSONcurl: (6) Could not resolve host: "path"

I think I know where I went wrong, maybe in the '--data '{"path":" "},' I think I'm putting the wrong path in this line, but I don't know exactly what I should put there, I try the path in the local machine and the path in Dropbox, but both of them don't works, and the docs of the dropbox don't make this much clear...

So, any help is welcome!

Thanks in advanced!

网友答案:

When making an API call like this to Dropbox API v2, the 'path' parameter should be the remote path in Dropbox. For files and folders in the account, this should start with a "/", followed by the rest of the path in the account, e.g., including any parent folders, etc.

The documentation for /2/files/delete includes a curl example that shows how this would work for a file Prime_Numbers.txt inside a folder 'math' inside a folder 'Homework':

curl -X POST https://api.dropboxapi.com/2/files/delete \
    --header "Authorization: Bearer ACCESS_TOKEN" \
    --header "Content-Type: application/json" \
    --data "{\"path\": \"/Homework/math/Prime_Numbers.txt\"}"

It's unclear from your question what exactly the path is for the file you're trying to delete, but you should format it and replace "/Homework/math/Prime_Numbers.txt" accordingly.

As far as the specific errors you're getting are concerned, there seems to be two different ones:

could not decode input as JSON

This indicates that the data in the body of your request, specified in this case via --data is not valid JSON.

Could not resolve host: "path"

This indicates that curl thought you were trying to connect to a host named path (instead of the desired api.dropboxapi.com). That may indicate a syntax issue with your curl command.

分享给朋友:
您可能感兴趣的文章:
随机阅读: