2013-11-24 32 views
1

我们有接受POST请求的WebApi服务。 POST请求中的信息具有此Unicode字符 - (http://www.fileformat.info/info/unicode/char/a1/index.htm使用卷曲 - 字符编码问题向WebApi发送POST请求

当我们使用Fiddler测试服务时,信息在服务器上正确接收。不过,虽然使用curl做的相同信息的POST,性格得到改变这一个从特价块 - http://www.fileformat.info/info/unicode/char/fffd/index.htm

为什么这知不知道正在发生的事情,以及我们如何能得到卷曲请求POST正确编码的东西,将不胜感激

编辑: 卷曲请求

curl --trace-ascii debug.txt -d "=VALT ¡ OFFER = '111501383'" http://localhost:25980/api/uni 

阿比控制器代码

// POST api/<controller> 
public string Post([FromBody]string value) 
{ 
// code to process the value 
} 

提琴手请求(使用作曲家选项卡)

POST http://localhost:25980/api/uni HTTP/1.1 
Accept: text/html, application/xhtml+xml, */* 
Accept-Language: en-IN,en;q=0.5 
User-Agent: Mozilla/5.0 (compatible; MSIE 10.0; Windows NT 6.2; WOW64; Trident/6.0) 
Content-Type: application/x-www-form-urlencoded; charset=US-ASCII 
Accept-Encoding: gzip, deflate 
Connection: Keep-Alive 
Content-Length: 47 
Host: localhost:25980 

"=VALT ¡ OFFER = '111501383'" 
+0

您是否可以添加发送请求的卷发代码。另外,'ApiContoller'代码会很有帮助。 –

+0

更新的问题与代码 – jbagavathi

+0

这是卷曲在Windows上吗?命令行上的非ASCII字符可能会非常棘手。这是一个unicode(/ U)控制台吗? – bzlm

回答

3

这是一个建议。我会尽力在今天晚些时候复制你的问题,并会更新答案。

Content-Type:application/x-www-form-urlencoded;字符集= US-ASCII

该行指定您的数据是使用US-ACSII编码方案,其中不包括¡字符编码。尝试使用此选项将其设置为UTF-8

-H "Content-Type: application/x-www-form-urlencoded; charset=utf-8" 
+0

我同意你的建议,但是看起来他们试图发送的字符实际上是ASCII 0xa1,这可能会导致卷曲。我猜他们实际上是发送UTF-8 0xc2a1。 – bzlm