My bad, you are right, the Content property is of the Document sub type and therefore you need the type segment. I'm surprised however that seems to work though without the namespace or namespace alias, it should read 'ibm.tm1.api.v1.Document' or, using the namespace alias, 'tm1.Document'. I'll make a note of this 'bug'!
Original Message:
Sent: Tue March 18, 2025 01:39 PM
From: Mahmut Yuksel
Subject: Modify / Create Application entries through REST API
Hi @Hubert Heijkers,
Many thanks for your explanation, finally it worked. I just want to correct the little detail in the PUT call as without it, it doesn't work for me.
PUT http://{{host}}:{{port}}/api/v1/Contents('Applications')/Contents('PlanningSample')/Contents('Name-of-document')/Document/Content
Content-Type:
application/octet-stream
And I want to share a powershell script that I used:
$applicationPath = "Analysis/Test"$file = "ET2019 Personnel.xlsx"$import_path = "E:\IBM Demos\24Retail"$splitAppPath = $applicationPath -split "/"if ($splitAppPath.Length -eq 1) { $formattedAppPath = "Contents('$($splitAppPath[0])')"} else { $formattedAppPath = ($splitAppPath | ForEach-Object { "Contents('$_')" }) -join "/"}$formattedFile = "Contents('"+ $file + ".blob')"$import_file_path = $import_path + '\' + $file[byte[]]$binaryContent = [System.IO.File]::ReadAllBytes("$import_file_path")$params_PUT = @{ Uri = "http://localhost:55130/api/v1/Contents('Applications')/" + $formattedAppPath + "/" + $formattedFile + "/Document/Content" Headers = @{ 'Authorization' = $psw} Method = 'PUT' ContentType = 'application/octet-stream' Body = $binaryContent} Invoke-RestMethod @params_PUT
------------------------------
Mahmut Yuksel
Original Message:
Sent: Tue March 18, 2025 01:22 AM
From: Hubert Heijkers
Subject: Modify / Create Application entries through REST API
Hi @Mahmut Yuksel,
Creating a document is a two step process. First you create (POST) the entity that represents the document and then you update (PUT) the contents to the Content property of the Document entry you created in the previous step.
So in your case you want to create a document by sending a:
```
POST http://{{host}}:{{port}}/api/v1/Contents('Applications')/Contents('PlanningSample')
Content-Type: application/json
{
"@odata.type\" : \"ibm.tm1.api.v1.Document",
"Name": "Name-of-document"
}
```
After the document is created you issue the second request which is a regular PUT request of writing the document's (read: file's) contents:
```
PUT http://{{host}}:{{port}}/api/v1/Contents('Applications')/Contents('PlanningSample')/Contents('Name-of-document')/Content
Content-Type:
application/octet-stream
<<the-raw-binary-content-of-the-file>>
```
Again, this second request is a generic HTTP PUT request to a file resource endpoint where the stream property of the target entity, the Content property in this case, is the target resource.
Hope this helps,
------------------------------
Hubert Heijkers
STSM, Program Director TM1 Functional Database Technology and OData Evangelist
Original Message:
Sent: Mon March 17, 2025 08:55 AM
From: Mahmut Yuksel
Subject: Modify / Create Application entries through REST API
Hi @Hubert Heijkers,
I try to create/publish an xlsx file(websheet) to a folder application (e.g. Applications/PlanningSample).
I know the rest api call, but what should be the body when creating a xlsx/xlsm document?
------------------------------
Mahmut Yuksel
Original Message:
Sent: Mon November 04, 2019 12:39 PM
From: Hubert Heijkers
Subject: Modify / Create Application entries through REST API
Hi Michael,
Creating those reference entities is just the same as any other type of entity, with the exception perhaps, if you haven't created views for example, that you have to specify the type as well.
So, using Planning Sample, if you wanted to add a reference to the "Budget Total Input" view from the plan_BudgetPlan cube into the "Planning Sample" folder under application you would POST using a URL similar to:
http://tm1server:12555/api/v1/Contents('Applications')/Contents('Planning Sample')/Contents
where the body would describe the 'Entry' you are trying to post to the contents of that folder, in this case, a 'ViewReference' as in:
{
"@odata.type":"tm1.ViewReference",
"Name":"Reference to plan_BudgetPlan's Budget Input Total View",
"View@odata.bind":"Cubes('plan_BudgetPlan')/Views('Budget Input Total')"
}
------------------------------
Hubert Heijkers
Original Message:
Sent: Tue October 29, 2019 02:53 AM
From: Michael Ehrenberger
Subject: Modify / Create Application entries through REST API
All those xxxReference
types inherit from the Entry
base type. You should be able to use any of the reference types in all the same places as an Entry
. Commonly, a Folder.Contents
would be the container collection you could POST
, PATCH
, DELETE
to
------------------------------
Michael Ehrenberger
Technical Analyst
IBM
Vienna
Original Message:
Sent: Fri October 25, 2019 08:22 AM
From: Michael Ehrenberger
Subject: Modify / Create Application entries through REST API
@here I have got the following question in one of my support tickets
*We would like to maintain application entries in PA through the REST API*
Using the REST API we tested and are able to achieve the following:
- Delete certain application entries
- Create new Folders
- Create and Update Workbooks
- Create Links (URLs/ref. to external files)
Additionally, we would like to create/update the following objects as application entries:
- ProcessReference
- ChoreReference
- DimensionReference
- SubsetReference
- CubeReference
- ViewReference
As I wasn't able to find any documentation on this, could someone please provide us with example REST calls for this second block? Or let me know if that is documented somewhere?
We are not asking how to create/update these PA objects. This is documented.
We are asking how to create references to these objects in the application tree folders through the REST API.
Using the client tools, you can publish views, processes, subsets, and other objects in the application tree.
We want to maintain them using the REST API. -> Workbooks and external links are working, and we are looking for the rest :)
Can someone help me out?
------------------------------
Michael Ehrenberger
------------------------------
#PlanningAnalyticswithWatson