Hi Fernando,
@Ryan Clapp Thank you for mentioning my pull request :)
@Fernando Hopkins here is the code how you can create all possible references:
Create folder:
POST /api/v1/Contents('Applications')/Contents
Content-Type: application/json
Body:
{
"@odata.type": "#ibm.tm1.api.v1.Folder",
"Name": "NewFolder"
}
Create doc:
POST /api/v1/Contents('Applications')/Contents('NewFolder')/Contents
Content-Type: application/json
Body:
{
"@odata.type": "#ibm.tm1.api.v1.Document",
"Name": "Excel template.xlsx"
}
Update doc content:
PUT /api/v1/Contents('Applications')/Contents('NewFolder')/Contents('Excel template.xlsx.blob')/Document/Content
Content-Type: application/octet-stream
Body:
[The document in binary format]
Create link:
POST /api/v1/Contents('Applications')/Contents('NewFolder')/Contents
Content-Type: application/json
Body:
{
"@odata.type": "#ibm.tm1.api.v1.Link",
"Name": "IBM Website",
"URL": "http://ibm.com"
}
Create view reference:
POST /api/v1/Contents('Applications')/Contents('NewFolder')/Contents
Content-Type: application/json
Body:
{
"@odata.type":"tm1.ViewReference",
"Name":"Reference to a View",
"View@odata.bind":"Cubes('Your cube')/Views('Your view')"
}
Create subset reference:
POST /api/v1/Contents('Applications')/Contents('NewFolder')/Contents
Content-Type: application/json
Body:
{
"@odata.type":"tm1.SubsetReference",
"Name":"Reference to a subset",
"Subset@odata.bind":"Dimensions('Your dim')/Hierarchies('Your hierarchy')/Subsets('Your subset')"
}
Create process reference:
POST /api/v1/Contents('Applications')/Contents('NewFolder')/Contents
Content-Type: application/json
Body:
{
"@odata.type":"tm1.ProcessReference",
"Name":"Reference process",
"Process@odata.bind":"Processes('Your process')"
}
Create chore reference:
POST /api/v1/Contents('Applications')/Contents('NewFolder')/Contents
Content-Type: application/json
Body:
{
"@odata.type":"tm1.ChoreReference",
"Name":"Reference to chore",
"Chore@odata.bind":"Chores('Your chore')"
}
Create dimension reference:
POST /api/v1/Contents('Applications')/Contents('Test')/Contents
Content-Type: application/json
Body:
{
"@odata.type":"tm1.DimensionReference",
"Name":"Reference to dim",
"Dimension@odata.bind":"Dimensions('Your dim')"
}
Cheers
------------------------------
Tomasz Brzoza
tomasz.brzoza@linde.com------------------------------
Original Message:
Sent: Thu December 05, 2019 03:38 AM
From: Ryan Clapp
Subject: Trouble creating DocumentReference Entries with REST API
There is a pending pull request for tm1py that might be of help.
https://github.com/cubewise-code/tm1py/commit/6f81163bf6167032366bad22d552fc24df332795
Ryan Clapp
AWS Business Systems
Sr. Manager
Sent from my mobile device
Original Message------
Hello All,
I'm having some trouble creating DocumentReference entries in the Applications Folders using the REST API. I have not been able to find a full Body example, so not sure what is wrong... I believe it should be in the way I'm defining the "Document" property.
I have successfully created Link entries and Folder entries, and I was able to change the file Content of existing DocumentReference entries.
The problem I have is creating them from scratch.
Here's the code I use:
$Uri = $URLPref + "/api/v1/Contents('Applications')/Contents('Uploads')/Contents('Germany')/Contents"
$JsonBody = @"
{"@odata.type": "tm1.DocumentReference",
"ID": "Upload.xlsx.blob",
"Name": "Upload.xlsx",
"Document": {
"ID": "Upload.xlsx",
"Name": "Upload.xlsx",
"Size": 0,
"LastUpdated": "",
"Content": "AAAA"
}
}
"@
Invoke-RestMethod -Uri $Uri -Method POST -Headers $Headers -Body $JsonBody -ContentType "application/json"
The error I get is: "Could not find entity reference in payload."
What am I getting wrong?
Thanks,
------------------------------
Fernando Hopkins
------------------------------
#PlanningAnalyticswithWatson