SharePoint 2013 REST API and Charset Problem

Posted Yorum yapınSharepoint 2013 içinde yayınlandı

I’ve been on a project lately.The project was to migrate contents from a farm to another.Since there was corporate rules like a bank we couldnt use Content Migration tool in CA so our only option was to use SharePoint REST API.

Whenever i sent values from a list in farm to another list in another farm,i had problems with non-english chars.

For example; characters like “İ”,”Ç”,”Ğ” arent ASCII supported so my only option was to use “Encoding”

There are a couple known drawbacks while using Encoding with HttpWebRequest so i implemented those too in my code below:

[sourcecode language=”csharp”]
Encoding utf8NoBom = new UTF8Encoding(false);
Byte[] itemPostData = utf8NoBom.GetBytes(itemPostBody);
var datak = utf8NoBom.GetString(itemPostData);
itemRequest.ContentLength = utf8NoBom.GetByteCount(datak);
itemRequest.MaximumResponseHeadersLength = -1;
[/sourcecode]

 

Hope it helps!