【发布时间】:2020-11-18 18:00:41
【问题描述】:
我正在浏览 Azure Data Lake Storage Gen2 的 REST API 列表,当我从 CLI/Postman 调用 api 时遇到问题。
我刚从简单的获取请求 path list api 开始。
但响应如下
{"error":{"code":"InvalidHeaderValue","message":"The value for one of the HTTP headers is not in the correct format.\nRequestId:ecb96bb0-501f-0030-2578-65cf12000000\nTime:2020-07-29T07:20:35.6240747Z"}}
搜索后找到create directory/file的示例代码并尝试创建目录但得到类似的响应
提出请求
curl -i -X PUT -H "x-ms-version: 2020-07-29" -H "content-length: 0" -H "Authorization: Bearer $ACCESS_TOKEN" "https://$AccountName.dfs.core.windows.net/mydata?resource=filesystem"
对上述请求的回应
% Total % Received % Xferd Average Speed Time Time Time Current
Dload Upload Total Spent Left Speed
100 202 100 202 0 0 115 0 0:00:01 0:00:01 --:--:-- 115HTTP/1.1 400 The value
for one of the HTTP headers is not in the correct format.
Content-Length: 202
Content-Type: application/json;charset=utf-8
Server: Windows-Azure-HDFS/1.0 Microsoft-HTTPAPI/2.0
x-ms-request-id: 8d615c77-001f-0070-2b79-65c82a000000
Date: Wed, 29 Jul 2020 07:25:54 GMT
{"error":{"code":"InvalidHeaderValue","message":"The value for one of the HTTP headers is not in the correct format.\nRequestId:8d615c77-001f-0070-2b79-65c82a000000\nTime:2020-07-29T07:25:55.9048230Z"}}
对于身份验证,我使用https://login.microsoftonline.com/{{tenantID}}/oauth2/token?,然后使用下面的代码在测试部分捕获不记名令牌。
pm.test(pm.info.requestName, () => {
pm.response.to.not.be.error;
pm.response.to.not.have.jsonBody('error');
});
pm.globals.set("bearerToken", pm.response.json().access_token);
pm.test(pm.info.requestname, ()=>{
pm.response.to.not.be.error;
pm.response.to.not.have.jsonBody('error');
})
pm.globals.set('BearerToken',("Bearer ").concat(pm.response.json().access_token));
谁能告诉我哪里出了问题?
根据屏幕截图的要求更新问题。
在做了这么多试验后发现filesystem-list 我得到了响应,但是path-list 得到错误说AuthorizationPermissionMismatch 和403 状态码。
文件系统列表:
路径列表:
失败的标题
【问题讨论】:
-
您的令牌的资源是什么?应该是
https://storage.azure.com -
IN 资源使用
https://management.azure.com/并尝试了您的建议,但响应相同。 -
您的资源应该是
https://storage.azure.com。我之前说过这个吗?为什么是的,是的,我做到了 -
@HongOoi 尝试使用
https://storage.azure.com仍然是相同的响应。{"error":{"code":"AuthorizationPermissionMismatch","message":"This request is not authorized to perform this operation using this permission.\nRequestId:8cb9734d-f01f-0090-19b8-6c4bb3000000\nTime:2020-08-07T12:44:57.8346082Z"}} -
@HongOoi 告诉我它是如何为
file system - listAPI 工作的?
标签: azure rest postman azure-storage azure-data-lake