mishso
mishso

Reputation: 33

Azure File Share API - Invalid Header Format for x-ms-version

I am trying to format a request to Azure's File API and keep getting the invalid format for the x-ms-version

Error i am getting:

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

The headers in the request look like this:

Headers:

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

Here is the code I am using... ( i did put the request in the Headers object too and it does the same thing)

// 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);
                    }

        )

Upvotes: 1

Views: 773

Answers (1)

mishso
mishso

Reputation: 33

"Headers" to headers... now i just have to get the shared access key to work

Upvotes: 1

Related Questions