【发布时间】:2018-08-21 12:33:20
【问题描述】:
根据 question 的建议和 API 文档(例如 Blob service REST API),我在标题中指定了 x-ms-version。我的代码适用于 Azurite,并通过 Azure 进行身份验证,但返回一个
HTTP/1.1 400 The value for one of the HTTP headers is not in the correct format.
xml正文有更多细节:
<Error>
<Code>InvalidHeaderValue</Code>
<Message>The value for one of the HTTP headers is not in the correct format.
RequestId:d39d2cad-301e-009e-1546-3940de000000
Time:2018-08-21T11:58:14.2369850Z</Message>
<HeaderName>x-ms-version</HeaderName>
<HeaderValue>2017-01-19</HeaderValue>
</Error>
我的猜测不是格式,而是值。如何找到正确的值,甚至是我可以尝试一次运行一个的所有可能值的列表,或者是否有人知道这是一个误导性错误,我需要寻找其他地方?
在玩这个的同时,又会生成一个x-ms-version=2015-02-21。
HTTP/1.1 400 One of the request inputs is out of range.
这是请求:
-> GET /mike-ecu-test?restype=container&comp=list HTTP/1.1
-> Host: mikeecutest.blob.core.windows.net
-> User-Agent: libcurl/7.54.0 r-curl/3.1 httr/1.3.1
-> Accept-Encoding: gzip, deflate
-> Accept: application/json, text/xml, application/xml, */*
-> Authorization: SharedKey mikeecutest/mike-ecu-test:9j5XodD9OIslzMnzHXiU7c76EpOXFi5jeQITbHk/Y8g=
-> x-ms-date: Wed, 22 Aug 2018 01:35:06 GMT
-> x-ms-version: 2018-03-28
这是生成它的 r 代码,代码的功劳是这个 question 的答案 4
library("httr")
azureout <- function(){
url <- "http://mikeecutest.blob.core.windows.net/mike-ecu-test?restype=container&comp=list"
sak <- "dfgwhsfhsfg.....hjdkfgs=="
requestdate<-format(Sys.time(),"%a, %d %b %Y %H:%M:%S %Z", tz="GMT")
msapiversion<- "2018-03-28"
signaturestring<-paste0("GET",paste(rep("\n",12),collapse=""),
"x-ms-date:",requestdate,
"x-ms-version:",msapiversion,"\n",
"mikeecutest", "\n",
"comp:list","\n",
"restype:container")
headerstuff<-add_headers(Authorization=paste0("SharedKey mikeecutest/mike-ecu-test:",
RCurl::base64(digest::hmac(key=RCurl::base64Decode(sak, mode="raw"),
object=enc2utf8(signaturestring),
algo= "sha256", raw=TRUE))),
`x-ms-date`=requestdate,
`x-ms-version`=msapiversion)
content(GET(url,config = headerstuff, verbose() ))
}
存储 API 版本2018-03-28 生成:
<- HTTP/1.1 400 One of the request inputs is out of range.
存储 API 版本2018-02-01 生成:
<- HTTP/1.1 400 The value for one of the HTTP headers is not in the correct format.
【问题讨论】:
-
请求时间是UTC吗?
标签: r azure azure-storage