gpt4 book ai didi

curl - 使用 Curl 向 Web Api 发出 POST 请求 - 字符编码问题

转载 作者:行者123 更新时间:2023-12-03 23:29:49 25 4
gpt4 key购买 nike

我们有一个接受 POST 请求的 WebApi 服务。 POST 请求中的信息具有此 Unicode 字符 - ¡ ( http://www.fileformat.info/info/unicode/char/a1/index.htm )

当我们使用 Fiddler 测试服务时,信息在服务器上正确接收。但是在使用 curl 执行相同信息的 POST 时,字符会从 Specials 块更改为这个字符 - http://www.fileformat.info/info/unicode/char/fffd/index.htm

关于为什么会发生这种情况以及我们如何获得 Curl 请求以 POST 正确编码的内容的任何想法将不胜感激

编辑:
curl 请求

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

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

Fiddler 请求(使用 Composer 选项卡)
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'"

最佳答案

这是一个建议。我将在今天晚些时候尝试复制您的问题并更新答案。

Content-Type: application/x-www-form-urlencoded; charset=US-ASCII



此行指定您的数据使用 US-ACSII 进行编码编码方案,不包括 ¡特点。尝试将其设置为 UTF-8使用此选项:
-H "Content-Type: application/x-www-form-urlencoded; charset=utf-8"

关于curl - 使用 Curl 向 Web Api 发出 POST 请求 - 字符编码问题,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/20174259/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com