Planning Analytics

 View Only
  • 1.  Trouble creating DocumentReference Entries with REST API

    Posted Wed December 04, 2019 08:34 AM
    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


  • 2.  RE: Trouble creating DocumentReference Entries with REST API

    Posted Thu December 05, 2019 03:38 AM
    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





  • 3.  RE: Trouble creating DocumentReference Entries with REST API

    Posted Thu December 05, 2019 06:19 AM
    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
    ------------------------------



  • 4.  RE: Trouble creating DocumentReference Entries with REST API

    Posted Mon December 09, 2019 04:06 AM
    Very much appreciated. 
    Just one note, the API returned error when updating the document content using PUT. I had to use PATCH instead. 

    Thank you very much for the guidance!

    ------------------------------
    Fernando Hopkins
    ------------------------------



  • 5.  RE: Trouble creating DocumentReference Entries with REST API

    IBM Champion
    Posted Mon December 23, 2019 09:09 AM
    Hello everyone,

    I think I found an inconsistency around Private Applications in the TM1 REST API
    The API does allow me to create a pivate application. Like this one:

    POST /api/v1/Contents('Applications')/Contents('Planning%20Sample')/PrivateContents
    {"@odata.type": "tm1.CubeReference", "Name": "SomeApplication", "Cube@odata.bind": "Cubes(\'SomeCube\')"}

    However, if I then want to retrieve this private application, I get a 400 Bad Request.

    GET /api/v1/Contents('Applications')/Contents('Planning%20Sample')/PrivateContents('SomeApplication.cube')?$expand=Cube($select=Name)

    In the response it says:
    "Unable to resolve cube reference."

    In the tm1server.log I find this message:
    Attempt to return URL handle for a private cube. Cubes cannot be private

    In Architect, I can open the Application without issues.
    The described behaviour applies for all kind of applications, except for Documents, Folders and Links.

    Am I doing something wrong ? 

    Cheers,

    Marius

    ------------------------------
    Marius Wirtz
    ------------------------------



  • 6.  RE: Trouble creating DocumentReference Entries with REST API

    Posted Mon January 06, 2020 12:14 PM
    Hi Marius,

    You are doing nothing wrong, unfortunately;-), which means, and it took me sec because it is actually the POST that has a bug in its implementation, there is a bug in the TM1 server code.

    So noted, I'll fix that shortly!

    Hubert

    ------------------------------
    Hubert Heijkers
    ------------------------------



  • 7.  RE: Trouble creating DocumentReference Entries with REST API

    IBM Champion
    Posted Mon January 06, 2020 04:50 PM
    Thanks!

    ------------------------------
    Marius Wirtz
    ------------------------------