刚开始看到一个问题,在Chrome中使用Headers类添加headers是小写的。也就是说,当我添加Content-Type时,它被更改为content-type。这似乎阻止了调用Graph,因为我得到了如下的响应。我确认了标题是存在的,但是,它已经被转换为小写。是否可以更新该服务以接受不区分大小写的标头?
{
"status": 415,
"statusText": "Unsupported Media Type",
"data": {
"responseBody": {
"error": {
"code": "",
"message": "The request contains an entity body but no Content-Type header. The inferred media type 'application/octet-stream' is not supported for this resource.",
"innerError": {
"request-id": "7032e0e0-32f5-47b5-a328-de8c12576cd4",
"date": "2018-03-16T13:28:30"
}
}
},
"responseHeaders": {}
},
"name": "ProcessHttpClientResponseException"
}以下是请求的头部:
POST /v1.0/me/onenote/notebooks? HTTP/1.1
Host: graph.microsoft.com
Connection: keep-alive
Content-Length: 32
Pragma: no-cache
Cache-Control: no-cache
authorization: Bearer {token}
Origin: https://{tenant}.sharepoint.com
User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/64.0.3282.186 Safari/537.36
content-type: application/json;
Accept: */*
Referer: https://{tenant}.sharepoint.com/sites/dev/sitepages/webpacktest.aspx
Accept-Encoding: gzip, deflate, br
Accept-Language: en-US,en;q=0.9
DNT: 1发布于 2018-03-16 22:49:54
这是用户错误。正在将content-type的值发送为"application/json;“。删除";“并发送"application/json”可以解决这个问题。大小写不是问题。
https://stackoverflow.com/questions/49322318
复制相似问题