We are aware of the issue with the badge emails resending to everyone, we apologise for the inconvenience - learn more here.

Forum Discussion

foggy748's avatar
foggy748
Explorer | Level 4
2 years ago

Problem with upload API and character with accent

Hello,

 

I have some problème with the upload API. When my fichier contain accent, the API return a status 401 and when I change the character without the accent it works. But in french, we need the accent. I want to know if there is a solution for this?

 

For the moment I use unicode() for change automatically characters that are problematic.

 

This is the code I use for uploading a file with the API:

 

 

 

 

return await axios({
    url: url,
    method: 'post',
    data: metadata,
    headers: {
      'Authorization': 'Bearer ' + stockageInfo.token,
      'Content-Type': 'application/octet-stream',
      'Dropbox-API-Arg': JSON.stringify({
        path: dossierId + '/' + unidecode(titre) + '.' + ext,
        mode: 'overwrite'
      })
    }
  }).then((d) => {
    return d.data.id
  }).catch((e) => {
    // statements
    console.log(e)
    return null
  })

 

 

 

 

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

    Hi foggy748,

    Unfortunately, Dropbox API doesn't support latest specifications for using unicode during json encoding. You have to use 7-bit json ASCII encoding (the previous specifications). All symbols that don't fit in 7 bits and all special symbols have to be tagged properly.

    Hope this helps.

    • foggy748's avatar
      foggy748
      Explorer | Level 4

      Hey,

       

      So, if I understand transform this word "Définir" to "D\u00e9finir" works?

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

        foggy748 wrote:

        ...

        So, if I understand transform this word "Définir" to "D\u00e9finir" works?


        Correct. It should work, at least. Usually this is done automatic by most json libraries, when properly initialized.

         

        Add: To be sure that everything is correct, dump the output of JSON.stringify. 😉 Take a look here for prototyping the call.

        Good luck.

About Dropbox API Support & Feedback

Node avatar for Dropbox API Support & Feedback

Find help with the Dropbox API from other developers.

5,877 PostsLatest Activity: 3 minutes ago
325 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!