【问题标题】:Azure File Share API - Invalid Header Format for x-ms-versionAzure 文件共享 API - x-ms-version 的标头格式无效
【发布时间】:2018-10-12 01:38:10
【问题描述】:

我正在尝试格式化对 Azure 文件 API 的请求并不断收到 x-ms-version 的无效格式

我得到的错误:

<Message>The value for one of the HTTP headers is not in the correct format.\nRequestId:<ID>\nTime:2018-10-11T15:40:32.1744262Z</Message><HeaderName>x-ms-version</HeaderName>

请求中的标头如下所示:

标题:

{ Authorization: 'SharedKey ACCOUNT:KEY' },
 'x-ms-date': 2018-10-11T15:18:47.561Z,
 'x-ms-version': '2018-03-28'

这是我正在使用的代码...(我也确实将请求放入 Headers 对象中,它做同样的事情)

// Create an HMAC using the storage account key
        const hmac = crypto.createHmac('sha256', key);

        // Build the Shared Key Signature
        var date = new Date();
        var apiVersion = "2018-03-28";

        var stringToSign = "GET\n\n\n\n\n\n\n\n\n\n\n\nx-ms-date:"+ date + "\nx-ms-version:" + apiVersion + "\n/" + req.body.name + "\ncomp:list";


        var utf8String = Buffer.from(stringToSign).toString('UTF8');

        hmac.update(utf8String);

        var signature = hmac.digest('base64');




        // Make the request
        request
            .get(req.body.fileEndpoint + '?comp=list',
                {
                    "Headers": {
                        "Authorization" : "SharedKey " + req.body.name + ":" + signature
                    },
                    "x-ms-date": date,
                    "x-ms-version" : apiVersion
                    }, function(error, response, body) {
                        console.log(error);
                        console.log(response);
                        console.log(body);
                    }

        )

【问题讨论】:

    标签: node.js azure azure-storage azure-files


    【解决方案1】:

    “标题”到标题...现在我只需要获取共享访问密钥即可工作

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 2018-04-15
      • 1970-01-01
      • 1970-01-01
      • 2021-05-20
      • 2021-05-06
      • 1970-01-01
      • 2017-12-22
      • 1970-01-01
      相关资源
      最近更新 更多