IBM Support

How to Upload Files to Planning Analytics as a Service Database using REST API

How To


Summary

The following document provides steps to uploads files to a Planning Analytics as a Service database using the REST API

Environment

Before you begin, please be sure you are familiar with the API and can interact with a database.  Please see the following for further details:
https://www.ibm.com/support/pages/node/7137883

Steps

SIMPLE FILE UPLOADS:
CREATE A FOLDER:
The following POST 
request will create a folder named TestFolder1 in the root directory of your database:
POST: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents
Content-Type: application/json
Cookie: paSession=<paSession_cookie>
Body:
{
    "@odata.type": "#ibm.tm1.api.v1.Folder",
    "Name": "TestFolder1"
}

CREATE A FILE:
The following POST request will create an empty file named TestFile1.txt in the TestFolder1 directory of your database:
POST: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents('TestFolder1')/Contents
Content-Type: application/json
Cookie: paSession=<paSession_cookie>
Body:
{
    "@odata.type": "#ibm.tm1.api.v1.Document",
    "Name": "TestFile1.txt"
}

ADD FILE CONTENTS (SIMPLE TEXT EXAMPLE):
The following PUT request will populate the file named TestFile1.txt in the TestFolder1 directory of your database with the supplied contents:
PUT: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents('TestFolder1')/Contents('TestFile1.txt')/Content
Content-Type: text/plain
Cookie: paSession=<paSession_cookie>
Body:
col1,col2,col3
r1,r1,r1
r2,r2,r2
r3,r3,r3

ADD FILE CONTENTS (FILE TYPE EXAMPLE):
The following PUT request will populate the file named TestFile1.txt in the TestFolder1 directory of your database with the supplied contents:
PUT: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents('TestFolder1')/Contents('TestFile1.txt')/Content
Content-Type: image/jpeg
Cookie: paSession=<paSession_cookie>
Body:
<binary file contents>


MULTIPART UPLOADS:
Multipart upload allows you to upload a single object as a set of parts using the Contents Endpoint. Each part is a contiguous portion of the object's data. You can upload these object parts independently and in any order. If transmission of any part fails, you can retransmit that part without affecting other parts. After all parts of your object are uploaded, calling mpu.Complete Action on the upload assembles these parts and creates the object. In general, when your object size reaches 100 MB, you should consider using multipart uploads instead of uploading the object in a single operation.
 
MPU UPLOAD - CREATE A FILE:
The following POST request will create an empty file named TestFile1.txt in the TestFolder1 directory of your database:
POST: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents('TestFolder1')/Contents
Content-Type: application/json
Cookie: paSession=<paSession_cookie>
Body:
{
    "@odata.type": "#ibm.tm1.api.v1.Document",
    "Name": "testMPUFile1.txt"
}

INITIATE MULTIPART UPLOAD OF FILE CONTENTS:
The following POST request will populate the file named TestFile1.txt in the TestFolder1 directory of your database with the supplied contents:
*You must save the UploadID in the response of the request: Example: "UploadID": "8620e00d"

POST: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents('TestFolder1')/Contents('testMPUFile1.txt')/Content/mpu.CreateMultipartUpload
Content-Type: application/json
Cookie: paSession=<paSession_cookie>
Body:
{}

UPLOAD FILE PART 1:
The following POST request will populate the file named TestFile1.txt in the TestFolder1 directory of your database with the supplied contents:
*Make note of the etag and PartNumber in the response of this request
POST: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents('TestFolder1')/Contents('testMPUFile1.txt')/Content/!uploads('8620e00d')/Parts
Content-Type: text/plan
Cookie: paSession=<paSession_cookie>
Body:
This is the first part

UPLOAD FILE PART 2:
The following POST request will populate the file named TestFile1.txt in the TestFolder1 directory of your database with the supplied contents:
*Make note of the etag and PartNumber in the response of this request
POST: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents('TestFolder1')/Contents('testMPUFile1.txt')/Content/!uploads('8620e00d')/Parts
Content-Type: text/plan
Cookie: paSession=<paSession_cookie>
Body:
This is the second part

CHECK UPLOADED FILE PARTS:
The following GET request will retrieve the status of parts uploaded as part of file named TestFile1.txt in the TestFolder1 directory of your database:
GET: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents('TestFolder1')/Contents('testMPUFile1.txt')/Content/!uploads('8620e00d')/Parts
Content-Type: text/plan
Cookie: paSession=<paSession_cookie>

COMPLETE THE MULTIPART UPLOAD:
The following POST request will assemble the parts uploaded and create the TestFile1.txt in the TestFolder1 directory of your database:
*Make note of the etag and PartNumber in the response of this request
POST: https://us-east-1.planninganalytics.saas.ibm.com/api/{{tenant}}/v0/tm1/{{tm1db}}/api/v1/Contents('Files')/Contents('TestFolder1')/Contents('testMPUFile1.txt')/Content/!uploads('8620e00d')/mpu.Complete
Content-Type: text/plan
Cookie: paSession=<paSession_cookie>
Body:
{
    "Parts": [
        {
            "PartNumber": "177e0aa3",
            "ETag": "8abcd163d04cfdc59ba5a9772d971528c7ff4e5"
        },
        {
            "PartNumber": "3d19fdcb",
            "ETag": "babcdfb9cfe662c43d6092b27050265204f138b9"
        }
    ]
}

Document Location

Worldwide


[{"Type":"MASTER","Line of Business":{"code":"LOB10","label":"Data and AI"},"Business Unit":{"code":"BU048","label":"IBM Software"},"Product":{"code":"SSEAI8G","label":"Planning Analytics as a Service"},"ARM Category":[{"code":"a8m3p000000GoaGAAS","label":"Planning Analytics-\u003EPlanning Analytics as a Service Specific"}],"ARM Case Number":"TS016723615","Platform":[{"code":"PF025","label":"Platform Independent"}],"Version":"All Versions"}]

Document Information

More support for:
Planning Analytics as a Service

Component:
Planning Analytics->Planning Analytics as a Service Specific

Software version:
All Versions

Document number:
7160405

Modified date:
16 July 2024

UID

ibm17160405

Manage My Notification Subscriptions