Reply
Member
Posts: 1
Registered: ‎12-10-2009

C# AIM code and non-english character

I use the C# sample posting code from the developer website, it works for all-english address. However, when I use non-english addresses like Montréal, it throws

Bytes to be written to the stream exceed the Content-Length bytes size specified.

when calling

myWriter.Write(strPost);
---> myWriter.Flush(); // throw exception
what I found out is the sample code using strPost.Length as HttpWebRequest.ContentLength, but non-english characters count more than 1 in stream. I tried other method,

like use

byte[] buffer = System.Text.Encoding.UTF8.GetBytes(strPost);

objRequest.ContentLength = buffer.Length;

...

myWriter =

new StreamWriter(objRequest.GetRequestStream(), System.Text.Encoding.UTF8);

myWriter.Write(buffer);

myWriter.Close();

I got Cannot close stream until all bytes are written.

 

So I wonder what's the correct code should be.

All Star
Posts: 1,072
Registered: ‎08-17-2009

Re: C# AIM code and non-english character

Hey chengbao,

 

Unfortunately, non-English characters are not allowed in any of our APIs. Try submitting the request with standard English characters and see if that works.

 

Thanks,

Michelle

Developer Community Manager

Member
Posts: 1
Registered: ‎06-07-2011

Re: C# AIM code and non-english character

Michelle - 


Can you please provide sample code on how to handle International Address? Or Should we not pass the address if the country is outside US and Canada? 

 

Please help as we are having trouble with international customers trying to checkout.

 

Thanks

TechMate  

Member
Posts: 1
Registered: ‎02-02-2013

Re: C# AIM code and non-english character

We're having this same issue.  Was a workaround ever suggested?

 

I've seen another post at - http://forums.asp.net/t/1396312.aspx/1 - which suggests that this command might work:

request.GetPreloadedEntityBody();

 

Can you advise please?

 

Thanks,

Rafi

Administrator Administrator
Administrator
Posts: 563
Registered: ‎08-03-2011

Re: C# AIM code and non-english character

 

Hi,
 
You should no longer see any issues from Authorize.Net accepting these international characters. It looks like the error that you are seeing is something within the .Net architecture. Unfortunately, we don't have a workaround that we can provide you.
 
Thanks,
Joy