Posted in Sharepoint 2013

SharePoint 2013 REST API and Charset Problem

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:

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

 

Hope it helps!

Advertisements

Leave a Reply

Fill in your details below or click an icon to log in:

WordPress.com Logo

You are commenting using your WordPress.com account. Log Out / Change )

Twitter picture

You are commenting using your Twitter account. Log Out / Change )

Facebook photo

You are commenting using your Facebook account. Log Out / Change )

Google+ photo

You are commenting using your Google+ account. Log Out / Change )

Connecting to %s