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

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");