标题大小写内容类型与内容类型的问题

时间:2018-03-16 13:47:55

标签: json microsoft-graph

刚开始发现使用Headers类添加标题的Chrome设置较低的问题。即当我添加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

1 个答案:

答案 0 :(得分:0)

这是用户错误。将内容类型的值发送为" application / json;"。删除";"并发送" application / json"解决了这个问题。套管不是问题。