1

我正在尝试格式化对 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);
                    }

        )
4

1 回答 1

1

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

于 2018-10-11T17:38:10.407 回答