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

anildbest83's avatar
anildbest83
Explorer | Level 3
8 years ago

Accented characters in file name

I m using Dropbox V2 API  and when try to upload a file with name 'tête-à-tête' getting following error   Error in call to API function "files/upload_session/finish": HTTP header "Dropbox-API-Arg":...
  • Greg-DB's avatar
    8 years ago

    For these calls with the parameters in the header, you need to escape these characters. That is, when you use the “Dropbox-API-Arg” header, you need to make it “HTTP header safe”. This means using JSON-style “\uXXXX” escape codes for the character 0x7F and all non-ASCII characters.

     

    Some, but not all, languages/libraries do this for you. For example, in C#, using Json.NET/JsonTextWriter, that would look like:

     

    var sb = new StringBuilder();
    var textWriter = new JsonTextWriter(new StringWriter(sb));
    textWriter.StringEscapeHandling = StringEscapeHandling.EscapeNonAscii;
    
    // Write things to text writer
    textWriter.WriteStartArray();
    textWriter.WriteValue("Hello");
    ...
    
    var result = sb.toString().Replace("\x7f", "\\u007f");

     

    Or, using Json.NET/JsonConvert:

     

    var serializerSettings = new JsonSerializerSettings();
    serializerSettings.StringEscapeHandling = StringEscapeHandling.EscapeNonAscii;
    
    var result = JsonConvert.SerializeObject(..., serializerSettings);
    result = result.Replace("\x7f", "\\u007f");