I'm trying to upload document in Azure blob storage through REST API but getting authentication error.
Sharing request header and url-
message = bytes(sas_token, 'utf-8')
secret = bytes(key, 'utf-8')
signature = base64.b64encode(hmac.new(secret, message, digestmod=hashlib.sha256).digest())
signature = str(signature)
header = {
"x-ms-version": "2020-04-08",
"x-ms-date":"Fri, 12 Mar 2021 23:39:12 GMT",
"Content-Type": "application/pdf; charset=UTF-8" ,
"Content-Length": "1048576",
"x-ms-copy-source" : ""
"x-ms-blob-type": "BlockBlob",
"Authorization": "SharedKey myaccount:" + signature,
}
URL - "https://"+ account_name+".blob.core.windows.net/"+container_name+"/"+name
response- requests.put(url, headers=headers)
Response - <Response [400]>
<?xml version="1.0" encoding="utf-8"?><Error><Code>InvalidAuthenticationInfo</Code><Message>Authentication information is not given in the correct format. Check the value of Authorization header.
Also I'm not sure how should I pass document if my document location is OBJECT_LOCATION = "/home/meera/Downloads/download.pdf"
I want to upload this download.pdf file in blob storage.
Documentation following - https://docs.microsoft.com/en-us/rest/api/storageservices/put-blob