You need to enable JavaScript to run this app. Postman/CLI调用ADLS Gen2 REST API报400与path-list 403错误
优惠活动
大模型
产品
解决方案
定价
更多

Postman/CLI调用ADLS Gen2 REST API报400与path-list 403错误

ADLS Gen2 REST API 调用问题记录

背景

正在调研Azure Data Lake Storage Gen2(ADLS Gen2)的REST API列表,通过CLI或Postman调用时连续遇到异常。

首次调用:path list API

首先发起GET请求调用path list API,Postman的请求配置可参考附截图,返回响应如下:

{"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"}}

第二次尝试:创建目录的PUT请求

参考公开的创建目录/文件示例代码,尝试发起PUT请求创建目录,请求内容如下:

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"}}

两次请求均返回InvalidHeaderValue错误,提示HTTP头值格式不符合要求。

认证配置说明

获取访问令牌的接口地址为https://login.microsoftonline.com/{{tenantID}}/oauth2/token?,在Postman的Test模块通过以下代码捕获Bearer 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 API可正常返回响应
  • 调用path-list API时返回状态码403,错误码为AuthorizationPermissionMismatch
    对应配置截图可参考:
  • FileSystem List调用正常配置截图
  • Path List调用报错配置截图
  • 失败请求的Headers配置截图

疑问

上述调用异常的原因是什么?


内容的提问来源于stack exchange,提问作者Prateek Naik

相关产品推荐
方舟 Agent Plan

超全模态模型 × Harness 升级,最新支持 Deepseek-V4.1-Flash、GLM-5.3 系列、Doubao-Seedream-5.0-pro、Kimi-K3 (部分), 限时 9.9 元起

最近更新时间:2026.12.05 01:24:05