最后编辑于2020-07
使用的是百度的自然语言处理。
如果请求设置代理则会发生400 Bad Request错误!如果取消代理则恢复正常!
测试代码如下:
static void Main(string[] args)
{
Encoding.RegisterProvider(CodePagesEncodingProvider.Instance);
RestClient client = new RestClient("https://aip.baidubce.com");
//设置代理后接口返回400
//client.Proxy = new WebProxy("172.16.0.53",8888);
client.Encoding = Encoding.GetEncoding("GBK");
var request = new RestRequest("/rpc/2.0/nlp/v1/lexer", Method.POST);
request.AddHeader("Content-Type", "application/json");
request.AddQueryParameter("access_token", "your token");
request.AddJsonBody(new Dictionary
{
["text"] = "测试数据"
});
var response = client.Execute(request);
response.ContentEncoding = "GBK";
response.Content = Encoding.GetEncoding("GBK").GetString(response.RawBytes);
}
预期:希望能设置代理!
收藏
点赞
0
个赞
请登录后评论
TOP
切换版块
代理是指什么场景呢?