Upload a file using Essbase REST API Multipart endpoint
in Essbase
Summary:
Essbase REST API Multipart Upload loads an empty file.
Content (required):
I'm trying to upload a file using multipart upload via rest api using this document. The file is uploaded successfully with an etag but the file has no data. Also, how should I check the status of file upload for large files to identify when to commit the upload?
Version (include the version you are using, if applicable):
Version: 21.4.3.0.0
Code Snippet (add any code snippets that support your topic, if applicable):
Create Multipart File Upload:
url = "https://<IP>/essbase/rest/v1/files/upload-create/applications/test_app/Datamart/test.txt?overwrite=false?append=false"
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
file=open('test.txt','rb')
response = requests.request("POST", url, auth=<>, headers=headers,data=file, verify=False)
Upload File Part:
url2_1 = "https://<IP>/essbase/rest/v1/files/upload-part/applications/test_app/Datamart/test.txt?partNum=1&uploadId="+<uploadId>
url2_2 = "https://<IP>/essbase/rest/v1/files/upload-part/applications/test_app/Datamart/test.txt?partNum=2&uploadId="+<uploadId>
headers = {
'Accept': 'application/json',
'Content-Type': 'application/octet-stream'
}
response1 = requests.request("PUT", url2_1, auth=<>, data=file, headers=headers, verify=False)
response2 = requests.request("PUT", url2_2, auth=<>, data=file, headers=headers, verify=False)
Commit Partial File Upload:
url3 = "https://<IP>/essbase/rest/v1/files/upload-commit/applications/test_app/Datamart/test.txt?uploadId="+<uploadId>
headers = {
'Accept': 'application/json',
'Content-Type': 'application/json'
}
payload = json.dumps({"1":<etag1>,"2":<etag2>})
response = requests.request("POST", url3, auth=<>, headers=headers,data=payload, verify=False)
print(response.text)
OUTPUT:
{
"etag" : "65713xxxxxxxxxxxxx"
}
Tagged:
0