【发布时间】:2019-10-21 03:24:54
【问题描述】:
添加新标题“If-Match”
using (HttpContent content = new StringContent(serializedObject))
{
content.Headers.Remove("Content-Type");
content.Headers.Add("Content-Type", "application/json");
content.Headers.Remove("If-Match");
content.Headers.Add("If-Match", "XXXXXXXXXX");
}
抛出:
Misused header name. Make sure request headers are used with HttpRequestMessage, response headers with HttpResponseMessage, and content headers with HttpContent objects.
我可以添加任何其他标题
【问题讨论】:
-
您正在设置响应标头,但使用的是请求标头保留字?
-
使用的 api 需要将 If-Match 放在 PUT 的标头中
-
好的,不要在内容上设置它,而是在父级上设置它
标签: httpcontent