Can't upload filename with special character to google drive REST

前端 未结 2 1493
有刺的猬
有刺的猬 2021-01-16 22:56

I\'m getting error when I try to upload a file to google drive api with my web application and the file has an character with accent, like for example \'ç\'.

I\'m up

2条回答
  •  孤城傲影
    2021-01-16 23:21

    Following the peleyal's commentary I solved my problem. I'm still using rest calls and not drive api, but I checked out the drive api source code and find out that they are using the HttpRequestMessage class. Changing my code from WebRequest to HttpRequestMessage solved the problem:

    var request = new HttpRequestMessage(HttpMethod.Post, uri);
    string strData = new JavaScriptSerializer().Serialize(jsonObject);
    
    var content = new StringContent(strData, Encoding.UTF8, "application/json");
    content.Headers.ContentType = new System.Net.Http.Headers.MediaTypeHeaderValue("application/json");
    request.Content = content;
    

提交回复
热议问题