cancel
Showing results for 
Show  only  | Search instead for 
Did you mean: 
Announcements
Want to learn some quick and useful tips to make your day easier? Check out how Calvin uses Replay to get feedback from other teams at Dropbox 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: 

Re: Error 400 with Download API

Error 400 with Download API

arpit2011
Explorer | Level 4
Go to solution

Hello Experts,

 

I have a business requirement in which files could directly be uploaded from dropbox through my javascript based web application(SAPUI5). My application is SAP UI5 based web application and the files chosen from dropbox would be stored inSAP servers. To achieve this integration, I am using Dropbox chooser to get the file link and ID. I am passing this link or ID to /files/download API of Content-download endpoint. However, I am error 400 when I pass the file path and error 409 when I pass the file ID. Please check the screenshots for more details.

 

Error 400 - Bad Request: 

Error in call to API function "files/download": HTTP header "Dropbox-API-Arg": path: 'https://dl.dropboxusercontent.com/1/view/j70yl6got1o2x50/Test/testfile.docx' did not match pattern '(/(.|[\r\n])*|id:.*)|(rev:[0-9a-f]{9,})|(ns:[0-9]+(/.*)?)'

Error MessageError Message

Request Header 400.png

Error 409 - Conflict 

 

Request Header 409.png

 

 

Error 409.JPG

 

Please help me to resolve this issue and guide me on how can I achieve this requirement. 

 

Thanks and regards,

Arpit

1 Accepted Solution

Accepted Solutions

Greg-DB
Dropbox Staff
Go to solution

@arpit2011 I see that Здравко has already helpfully answered your questions. To confirm, a shared link is not a path, which is why you got that first error. A path would look like "/folder/file.ext".

 

You can use the ID instead as you attempted, but the /2/files/download endpoint will return that 'path/not_found' error if the app doesn't have access to the identified file. For example, the access token may be for a different account, as Здравко said, or if the app is registered for the "app folder" access type, the app won't have access to the file if it exists outside its app folder.

 

As for "How to get the access code in runtime through JS", getting an access token does initially require some manual user interaction, but you can store and re-use it after that. I recommend reading the OAuth Guide and authorization documentation for information on how that all works.

 

By the way, you should never share your access token, as you did here in your images. I've redacted them for you, but for the sake of security, you should disable that access token since it was posted publicly. You can do so by revoking access to the app entirely, if the access token is for your account, here. Or, you can disable just this access token using the API.

View solution in original post

8 Replies 8

Здравко
Legendary | Level 20
Go to solution

Hi @arpit2011,

Your first error comes from fact you haven't used proper file identifier or path, but a shared link. That's exactly meaning of the error message there. I'm not sure what's not clear.

Your second message shows that for some reason provided id don't identify a valid file anymore. Are you sure the id is actual? Every time a file gets recreated for some reason (intentionally or not) new id gets assigned! Also, are you sure the particular file (and the id) gets stored within the same account identified with the authentication token?

Anyway... Once you have a shared link already you can download the target file directly, without any Dropbox API call. 😉 Something like:

curl --remote-name-all https://dl.dropboxusercontent.com/1/view/j70yl6got1o2x50/Test/testfile.docx

... or equivalent call.

Hope this helps.

arpit2011
Explorer | Level 4
Go to solution

Hi @,

 

Thanks for helping me out. 

 

I am passing the ID which I am getting from the chooser function. I am not sure why the ID is being reassigned 😞 

 

Also, I do not want to download the file instead I want to store the files in SAP servers. The reason I am calling the download  API is I am trying to get the file data in arrayBuffer/BLOB so that I can upload the same in SAP servers. I hope this is the right way to get the file data. 

 

I passed the access token after generating from the App console. Is there a way or an API to get the token at the runtime?

 

Thanks again for helping me.

 

Best regards,

Arpit

Здравко
Legendary | Level 20
Go to solution

@arpit2011 wrote:
...

Also, I do not want to download the file instead I want to store the files in SAP servers. The reason I am calling the download  API is I am trying to get the file data in arrayBuffer/BLOB so that I can upload the same in SAP servers. I hope this is the right way to get the file data. 

...

Yes, yes, ... Of course.

I'm not saying you have to use my command. This is just for example that you can access the target file using the shared link itself, nothing more. As I have mentioned, you can use everything else ( "... or equivalent call" ). Use whatever is convenient for you to get a picture from link, for example (or anything else from wherever else), in arrayBuffer/BLOB to upload the same wherever you want. 😉 That's it.

Hope this adds additional clarity.

arpit2011
Explorer | Level 4
Go to solution

@Здравко wrote:

@arpit2011 wrote:
...

Also, I do not want to download the file instead I want to store the files in SAP servers. The reason I am calling the download  API is I am trying to get the file data in arrayBuffer/BLOB so that I can upload the same in SAP servers. I hope this is the right way to get the file data. 

...

Yes, yes, ... Of course.

I'm not saying you have to use my command. This is just for example that you can access the target file using the shared link itself, nothing more. As I have mentioned, you can use everything else ( "... or equivalent call" ). Use whatever is convenient for you to get a picture from link, for example (or anything else from wherever else), in arrayBuffer/BLOB to upload the same wherever you want. 😉 That's it.

Hope this adds additional clarity.


Thanks again. 

 

Still, the doubt persists. I still cannot pass the ID into the download API.

 

Also, How to get the access code in runtime through JS?

 

Thanks,

Arpit

Здравко
Legendary | Level 20
Go to solution

Read here and learn, if you want.

Good luck!

Greg-DB
Dropbox Staff
Go to solution

@arpit2011 I see that Здравко has already helpfully answered your questions. To confirm, a shared link is not a path, which is why you got that first error. A path would look like "/folder/file.ext".

 

You can use the ID instead as you attempted, but the /2/files/download endpoint will return that 'path/not_found' error if the app doesn't have access to the identified file. For example, the access token may be for a different account, as Здравко said, or if the app is registered for the "app folder" access type, the app won't have access to the file if it exists outside its app folder.

 

As for "How to get the access code in runtime through JS", getting an access token does initially require some manual user interaction, but you can store and re-use it after that. I recommend reading the OAuth Guide and authorization documentation for information on how that all works.

 

By the way, you should never share your access token, as you did here in your images. I've redacted them for you, but for the sake of security, you should disable that access token since it was posted publicly. You can do so by revoking access to the app entirely, if the access token is for your account, here. Or, you can disable just this access token using the API.

arpit2011
Explorer | Level 4
Go to solution

@Greg-DB wrote:

@arpit2011 I see that Здравко has already helpfully answered your questions. To confirm, a shared link is not a path, which is why you got that first error. A path would look like "/folder/file.ext".

 

You can use the ID instead as you attempted, but the /2/files/download endpoint will return that 'path/not_found' error if the app doesn't have access to the identified file. For example, the access token may be for a different account, as Здравко said, or if the app is registered for the "app folder" access type, the app won't have access to the file if it exists outside its app folder.

 

As for "How to get the access code in runtime through JS", getting an access token does initially require some manual user interaction, but you can store and re-use it after that. I recommend reading the OAuth Guide and authorization documentation for information on how that all works.

 

By the way, you should never share your access token, as you did here in your images. I've redacted them for you, but for the sake of security, you should disable that access token since it was posted publicly. You can do so by revoking access to the app entirely, if the access token is for your account, here. Or, you can disable just this access token using the API.


Thank you @Greg-DB for your help. I was able to successfully run the oAuth flow and fetch the token. 

 

Thanks for highlighting about the token. I have created a new app and deleted the old one. 

 

I would need one more help. Now that my integration is successful, I would like to know which and why of the following plans would be perfect for me. Please note that my only requirement is to Host an application which would help me use Dropbox Chooser and maintain redirect URLs for oAuth flow.  I do not want much storage too but I would be using this dropbox application in production. The end-users should be able to run the OAuth flow.

Dropbox plans.JPG

 

Thanks

Arpit 

Greg-DB
Dropbox Staff
Go to solution

@arpit2011 Any kind of Dropbox account can own and configure a production app, such as to enable use of the Chooser and OAuth flow, so if you don't need the extra features of an upgraded account, such as the extra storage, a free account would be sufficient.

Need more support?