You might see that the Dropbox Community team have been busy working on some major updates to the Community itself! So, here is some info on what’s changed, what’s staying the same and what you can expect from the Dropbox Community overall.

Forum Discussion

arpit2011's avatar
arpit2011
Explorer | Level 4
5 years ago

Error 400 with Download API

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 Message

Error 409 - Conflict 

 

 

 

 

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

 

Thanks and regards,

Arpit

  • Greg-DB's avatar
    Greg-DB
    5 years ago

    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.

  • Здравко's avatar
    Здравко
    Legendary | Level 20

    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's avatar
      arpit2011
      Explorer | Level 4

      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

      • Здравко's avatar
        Здравко
        Legendary | Level 20

        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.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,894 PostsLatest Activity: 3 hours ago
328 Following

If you need more help you can view your support options (expected response time for an email or ticket is 24 hours), or contact us on X or Facebook.

For more info on available support options for your Dropbox plan, see this article.

If you found the answer to your question in this Community thread, please 'like' the post to say thanks and to let us know it was useful!