#事故现场
向某api接口发送请求,返回406,如下:
The target resource does not have a current representation that would be acceptable to the user agent, according to the proactive negotiation header fields received in the request, and the server is unwilling to supply a default representation.
#解决方法
在request中加入Accept 头,值为"*/* ". 以C#代码为例,使用了RestSharp:
var client = new RestClient(config.Host);
var request = new RestRequest("xxx")
.AddJsonBody(new
{
page = 1,
pagesize = 1000
})
.AddHeader("applyId", config.APPKey)
.AddHeader("secretKey", config.APPSecret)
.AddHeader("Accept", "*/*");
var response = client.Post(request);
|