Cut the Clutter: Test Ignore Files Feature - sign up to become a beta tester here.

Forum Discussion

jonokivex's avatar
jonokivex
Helpful | Level 5
2 years ago
Solved

'View on dropbox' PDF embed returning Error 400

Greetings,

Visit: https://www.arclab.space/f/dropbox-pdf-test (password is password)
The PDF displays fine, but the 'view on dropbox' link returns error 400. This happens with all links, site-wide.
The actual share link used in the embed works fine if pasted into the address bar directly.

Is this an API glitch? 

Thanks for your time!

Jonathan.

  • Hi jonokivex,

    It's an easy workaround - just drop the last link parameter - "&dl=0". 😉 That's where your issue is coming from. Just put in your page something like:

     

    Dropbox.embed({link: "https://www.dropbox.com/scl/fi/uhd2iaccfc7szs9oa1tny/AL01-0301_77A-BELL-ROAD_EXISTING-SITE-PLAN-A_REV-A.pdf?rlkey=5eyu4p6ysx8zksely5tum6q3z"}, document.getElementById('dropbox-embed-container'));

     

    Hope this helps.

     

    By the way your application is not yet passed production approval despite there are too many "developers" already. Good luck.

     

    PS: When you put something in your website, use url-encoding only when needed, not everywhere!!! In particular encoding the ampersand makes your link invalid when opened later. URL-encode is usable when nesting one link in another, for instance - which is not the case now - you're passing the link as parameter (Embedder takes care for encoding whenever needed).

5 Replies

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

    Hi jonokivex,

    It's an easy workaround - just drop the last link parameter - "&dl=0". 😉 That's where your issue is coming from. Just put in your page something like:

     

    Dropbox.embed({link: "https://www.dropbox.com/scl/fi/uhd2iaccfc7szs9oa1tny/AL01-0301_77A-BELL-ROAD_EXISTING-SITE-PLAN-A_REV-A.pdf?rlkey=5eyu4p6ysx8zksely5tum6q3z"}, document.getElementById('dropbox-embed-container'));

     

    Hope this helps.

     

    By the way your application is not yet passed production approval despite there are too many "developers" already. Good luck.

     

    PS: When you put something in your website, use url-encoding only when needed, not everywhere!!! In particular encoding the ampersand makes your link invalid when opened later. URL-encode is usable when nesting one link in another, for instance - which is not the case now - you're passing the link as parameter (Embedder takes care for encoding whenever needed).

  • jonokivex's avatar
    jonokivex
    Helpful | Level 5
    2 years ago

    Great stuff Здравко ! Thank you. Worked a charm.

    But, I didn't understand the second half of your message. Can you clarify?
    What do you mean the application hasnt passed production approval?

    And regarding URL encoding, are you saying that instead of &raw=1 or &dl=1 etc, it should be:
    %26raw=1 , %26dl=1 
    ?

    Thanks!

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

    jonokivex wrote:

    ...
    But, I didn't understand the second half of your message. Can you clarify?
    What do you mean the application hasnt passed production approval?
    ...


    I mean exactly what I said. If some application is gonna be released for many user (i.e. public use) your application needs production approval. If not passed, your application use will be limited - in fact it's already limited. In spite, you can continue use it for Embedder. So, if you don't have mobile, desktop standalone application, or something else that require user approval - no problem.

     


    jonokivex wrote:

    ...
    And regarding URL encoding, are you saying that instead of &raw=1 or &dl=1 etc, it should be:
    %26raw=1 , %26dl=1 ?
    ...


    Oh..🤦 I messed the words. I mean HTML escaping not URL encoding. Hm..🤔 Regarding this question, you may have make your link symbols escaped unintentionally. The note of me is in just opposite direction! You must NOT change anything, but you have did it!!! Just a fragment of you page:

     

    var options = {
      // Shared link to Dropbox file
      link: "https://www.dropbox.com/scl/fi/uhd2iaccfc7szs9oa1tny/AL01-0301_77A-BELL-ROAD_EXISTING-SITE-PLAN-A_REV-A.pdf?rlkey=5eyu4p6ysx8zksely5tum6q3z&dl=0",
      file: {
        // Sets the zoom mode for embedded files. Defaults to 'best'.
        zoom: "best" // or "fit"
      },
      folder: {
        // Sets the view mode for embedded folders. Defaults to 'list'.
        view: "grid", // or "list"
        headerSize: "normal" // or "small"
      }
    }
    Dropbox.embed(options, document.getElementById('dropbox-embed-container'));

     

    What's doing "&" there? 🧐 Note, again, you are passing parameter in Javascript, not link in HTML! It's slightly different (in HTML escaping is used, but not in Javascript). 😉 Correct that what makes this mess.

    Hope it's a bit more clear now.

  • jonokivex's avatar
    jonokivex
    Helpful | Level 5
    2 years ago

    I notice that share links include &dl=0 in them, so the embedder documentation should include this tidbit about removing it.

    Здравко the &amp is generated by webflow so I cant control that, as the link with '&' is added via CMS entry.

    Thanks for clarifying about the app !

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

    jonokivex wrote:

    I notice that share links include &dl=0 in them, so the embedder documentation should include this tidbit about removing it.
    ...


    It's not there since removing is not something mandatory. In general it's not need to be removed. I proposed it as a workaround.

     


    jonokivex wrote:

    ...
    Здравко the &amp is generated by webflow so I cant control that, as the link with '&' is added via CMS entry.
    ...


    Hm.. It sounds like a bug... if there is not an option controlling that. 🤷 Inform the provider of your system.

    When you click "View on Dropbox", it opens whatever passed there as is (if passed &amp, including it).

    Good luck.

     

    PS: As a workaround on this escaped string (as provided by your CMS), you can use string as following template:

    "https://www.dropbox.com/scl/fi/uhd2iaccfc7szs9oa1tny/AL01-0301_77A-BELL-ROAD_EXISTING-SITE-PLAN-A_REV-A.pdf?rlkey=5eyu4p6ysx8zksely5tum6q3z&dl=0".replaceAll('&','&')

     

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback
Find help with the Dropbox API from other developers.6,038 PostsLatest Activity: 7 hours ago
415 Following

The Dropbox Community team is active from Monday to Friday. We try to respond to you as soon as we can, usually within 2 hours.

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!