C# 将元数据发布到sharepoint 2016内部部署:System.Text.DecoderFallbackException,带有特殊字符
我尝试在SharePoint列表中创建具有元数据的项。 其中一个metata包含一个法语“ç”字符,使sharepoint响应时出现500个错误,其中包括: 代码=-1,System.Text.DecoderFallbackException value=无法将索引147处的Unicode字符[E7]转换为指定的代码页C# 将元数据发布到sharepoint 2016内部部署:System.Text.DecoderFallbackException,带有特殊字符,c#,rest,sharepoint,C#,Rest,Sharepoint,我尝试在SharePoint列表中创建具有元数据的项。 其中一个metata包含一个法语“ç”字符,使sharepoint响应时出现500个错误,其中包括: 代码=-1,System.Text.DecoderFallbackException value=无法将索引147处的Unicode字符[E7]转换为指定的代码页 using (var client = new SpWebClient("https://intranet/Gestion") { Credentials = CurrentNe
using (var client = new SpWebClient("https://intranet/Gestion") { Credentials = CurrentNetworkCredential })
{
var payload = new JObject
{
["__metadata"] = new JObject { ["type"] = "SP.Data.ListeCommentaireGerantListItem" },
["Language"] = "Français (France)"
};
var requestUrl = $"/_api/web/lists/GetByTitle('{SHAREPOINT_LIST}')/items";
Dictionary<string, string> updateHeaders = null;
var r = client.ExecuteJsonWithDigest(requestUrl, "POST", updateHeaders, payload);
return Redirect("/");
}
使用(var客户端=新的SpWebClient(“https://intranet/Gestion“”{Credentials=CurrentNetworkCredential})
{
var有效负载=新作业对象
{
[“_metadata”]=new JObject{[“type”]=“SP.Data.listCommentAiregrantListItem”},
[“语言”]=“法语(法国)”
};
var requestUrl=$“/”api/web/lists/GetByTitle(“{SHAREPOINT\u LIST}”)/items“;
字典更新头=null;
var r=client.ExecuteJsonWithDigest(requestUrl,“POST”,updateHeaders,payload);
返回重定向(“/”);
}
spWebClient已经定义,基本上它添加了所有需要的头并简化了类中的身份验证
我试图在标题中添加“application/json;odata=verbose;charset=utf-8”,但出现了相同的错误
有什么帮助吗?尝试通过以下方式显式设置将字符串发送到
UTF8的编码:
示例
using (var client = new SPWebClient("https://contoso.sharepoint.com") { Credentials = credentials, Encoding = System.Text.Encoding.UTF8 })
{
//the remaining code goes here...
}
尝试通过以下方式显式设置发送和获取字符串到UTF8
的编码:
示例
using (var client = new SPWebClient("https://contoso.sharepoint.com") { Credentials = credentials, Encoding = System.Text.Encoding.UTF8 })
{
//the remaining code goes here...
}