Uploading A File via Rest API to ADL Gen2 - Return Error "The Content-Length request header must be zero"

Terry Longman 96 Reputation points
2021-09-20T17:48:27.907+00:00

I am using the REST API for Azure Data Lake Gen2 to upload a file, via the Path/Create

I have set the headers,

Authorization : Bearer xxxxx
Content-Type : <calculated when request is sent>

The body is a blob.

Then use the URL PUT https://{accountName}.{dnsSuffix}/{filesystem}/{path}?resource=file

It returns the error,

"error": {
"code": "ContentLengthMustBeZero",
"message": "The Content-Length request header must be zero.\nRequestId:d5ed69b7-801f-006b-6845-aeac2b000000\nTime:2021-09-20T17:35:53.4042248Z"
}

If I overide the Content-Length and set it to 0, then it works, but the file created is of 0 bytes, I want to use the binary from the body to create the file, but setting Content-Length to be the length of the body generates the above error. How should I be attaching the file to the request if the Content-Length must be 0 ?

Azure Data Lake Storage
Azure Data Lake Storage
An Azure service that provides an enterprise-wide hyper-scale repository for big data analytic workloads and is integrated with Azure Blob Storage.
1,529 questions
0 comments No comments
{count} votes

Accepted answer
  1. Terry Longman 96 Reputation points
    2021-09-20T18:18:26.067+00:00

    It's ok, I found this stackoverflow that explains the additional steps.

    https://stackoverflow.com/questions/62775789/create-path-in-adls-gen2-fails-because-of-missing-x-ms-blob-type

    0 comments No comments

0 additional answers

Sort by: Most helpful

Your answer

Answers can be marked as Accepted Answers by the question author, which helps users to know the answer solved the author's problem.