Register process via RestAPI

Post Reply
User avatar
orlando
Community Contributor
Posts: 167
Joined: Fri Aug 04, 2017 8:27 am
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: Office 365

Register process via RestAPI

Post by orlando »

Hello all,

is there a clever and quick way to register a process in a data model via the RestAPI if I have copied the process file from another data model - I would like to avoid restarting the database.
I found the command Process.Compile in IBM's RestAPI documentation - unfortunately IBM does not elaborate on this.
Or is there another way to achieve the goal?

I am happy about links and hints
TM1Py is currently not a solution, as I cannot install Python on my computer (long story).

Many greetings
orlando
Edward Stuart
Community Contributor
Posts: 247
Joined: Tue Nov 01, 2011 10:31 am
OLAP Product: TM1
Version: All
Excel Version: All
Location: Manchester
Contact:

Re: Register process via RestAPI

Post by Edward Stuart »

There are a few ways you 'could' do it quickly but it may be necessary to find out how you can do it first and then find a preferred method.

Are you able to install a REST Api Client like Postman? Do you have access to Powershell? Do you have access to ScriptLab in excel?
User avatar
scrumthing
Posts: 81
Joined: Tue Jan 26, 2016 4:18 pm
OLAP Product: TM1
Version: 11.x
Excel Version: MS365

Re: Register process via RestAPI

Post by scrumthing »

I think your main problem is that you have the process file which is not in the format the rest api would expect. For the rest api to accept your ti you would have to extract all necessary information from the file and create the json file which the rest api expects. If it is just code without parameters and variables and a data source that can be done easily. You could use the hidden property 'code' in the current tm1 version (which version are you on?) which should allow you to send over just the ti-code (the format is similar to the one which the git integration provides).

If you have a more complex code you should extract the proper json via the rest api (instead of copying the file) either by starting a local tm1 server or by extracting it from the source.

Hope that helps...
There is no OLAP database besides TM1!
User avatar
macsir
MVP
Posts: 782
Joined: Wed May 30, 2012 6:50 am
OLAP Product: TM1
Version: PAL 2.0.9
Excel Version: Office 365
Contact:

Re: Register process via RestAPI

Post by macsir »

I would suggest you to setup a new instance where you put all your process files. And In powershell, use Invoke-RestMethod to call the process endpoint to copy all processes over from the new instance. The syntax should be the same as what's been used in TM1py.
In TM1,the answer is always yes though sometimes with a but....
http://tm1sir.blogspot.com.au/
User avatar
orlando
Community Contributor
Posts: 167
Joined: Fri Aug 04, 2017 8:27 am
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: Office 365

Re: Register process via RestAPI

Post by orlando »

Edward Stuart wrote: Thu Apr 08, 2021 7:55 am There are a few ways you 'could' do it quickly but it may be necessary to find out how you can do it first and then find a preferred method.

Are you able to install a REST Api Client like Postman? Do you have access to Powershell? Do you have access to ScriptLab in excel?
Hi,

Postman & Powershell are available. Script Lab is new to me.

Best regards,
orlando
User avatar
orlando
Community Contributor
Posts: 167
Joined: Fri Aug 04, 2017 8:27 am
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: Office 365

Re: Register process via RestAPI

Post by orlando »

scrumthing wrote: Thu Apr 08, 2021 7:19 pm I think your main problem is that you have the process file which is not in the format the rest api would expect. For the rest api to accept your ti you would have to extract all necessary information from the file and create the json file which the rest api expects. If it is just code without parameters and variables and a data source that can be done easily. You could use the hidden property 'code' in the current tm1 version (which version are you on?) which should allow you to send over just the ti-code (the format is similar to the one which the git integration provides).

If you have a more complex code you should extract the proper json via the rest api (instead of copying the file) either by starting a local tm1 server or by extracting it from the source.

Hope that helps...
Hi,

what's the "hidden property code". We are using version 2.08 an 2.09.
It will be more complex code.

Best regards,
orlando
User avatar
orlando
Community Contributor
Posts: 167
Joined: Fri Aug 04, 2017 8:27 am
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: Office 365

Re: Register process via RestAPI

Post by orlando »

macsir wrote: Thu Apr 08, 2021 8:31 pm I would suggest you to setup a new instance where you put all your process files. And In powershell, use Invoke-RestMethod to call the process endpoint to copy all processes over from the new instance. The syntax should be the same as what's been used in TM1py.
Hi,

I can already see that the idea of simply copying the process, calling RestApi and registering the process will not work.
I found this: https://www.youtube.com/watch?v=EWltFli9yBA
Something like this would be enough for me, unfortunately he only shows and does not explain how he did it

best regards
orlando
User avatar
scrumthing
Posts: 81
Joined: Tue Jan 26, 2016 4:18 pm
OLAP Product: TM1
Version: 11.x
Excel Version: MS365

Re: Register process via RestAPI

Post by scrumthing »

orlando wrote: Fri Apr 09, 2021 7:14 am Hi,
what's the "hidden property code". We are using version 2.08 an 2.09.
It will be more complex code.
Best regards,
orlando
Check this out... https://github.com/bgregs514/vscode-tm1 ... -786979805
There is no OLAP database besides TM1!
MNI
Posts: 2
Joined: Fri Apr 09, 2021 12:47 am
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2017

Re: Register process via RestAPI

Post by MNI »

Hello,

i think it is better not copy the file hardly...When you have knowledge of REST API then call RestAPI Command to get Process Definition from SourceServer and then take these JSON Result and push it to your Target Server.

I'm built that exactly in a ASP.NET Web Tool and these works. Copy from Left (Source) to Right (Target) Server. Advantage is, that is automatically registered and usable on the Target server.

When you more help then let it know.
User avatar
Elessar
Community Contributor
Posts: 332
Joined: Mon Nov 21, 2011 12:33 pm
OLAP Product: PA 2
Version: 2.0.9
Excel Version: 2016
Contact:

Re: Register process via RestAPI

Post by Elessar »

hI,

I think this is what you need: viewtopic.php?f=3&t=15300&p=76080#p76080
Best regards, Alexander Dvoynev

TM1 and Data Science blog: 6th article - PAfE + VBA: Commit each cell without pressing “Commit” button.
bgregs
Posts: 77
Joined: Wed Sep 12, 2018 11:19 am
OLAP Product: TM1 / Planning Analytics
Version: 2.0
Excel Version: 2016

Re: Register process via RestAPI

Post by bgregs »

To register an absolute bare-bones process, the api call would simply be:

Code: Select all

POST/ <api_url>/Processes
and then just attach a basic JSON structure to the post call:

Code: Select all

{
        "Name": "",
        "PrologProcedure": "\r\n#****Begin: Generated Statements***\r\n#****End: Generated Statements****",
        "MetadataProcedure": "\r\n#****Begin: Generated Statements***\r\n#****End: Generated Statements****",
        "DataProcedure": "\r\n#****Begin: Generated Statements***\r\n#****End: Generated Statements****",
        "EpilogProcedure": "\r\n#****Begin: Generated Statements***\r\n#****End: Generated Statements****"
}
And that's it! Obviously there are more attributes like Parameters and Datasouce that can be added, but I would recommend setting up the above as a "template", pulling it into a JSON object, and then adding additional parameters to the object - it's just much easier to operate on an object programmatically, than it is to hack together a template file.
Wim Gielis
MVP
Posts: 3105
Joined: Mon Dec 29, 2008 6:26 pm
OLAP Product: TM1, Jedox
Version: PAL 2.0.9.18
Excel Version: Microsoft 365
Location: Brussels, Belgium
Contact:

Re: Register process via RestAPI

Post by Wim Gielis »

Hi,

I haven't experimented with it (yet) but would be PAFE API be an alternative ? In the end it's VBA so not terribly difficult (I assume :-) )

There's code here: https://ibm.github.io/paxapi/#rest-api
Best regards,

Wim Gielis

IBM Champion 2024
Excel Most Valuable Professional, 2011-2014
https://www.wimgielis.com ==> 121 TM1 articles and a lot of custom code
Newest blog article: Deleting elements quickly
User avatar
orlando
Community Contributor
Posts: 167
Joined: Fri Aug 04, 2017 8:27 am
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: Office 365

Re: Register process via RestAPI

Post by orlando »

MNI wrote: Fri Apr 09, 2021 3:12 pm Hello,

i think it is better not copy the file hardly...When you have knowledge of REST API then call RestAPI Command to get Process Definition from SourceServer and then take these JSON Result and push it to your Target Server.

I'm built that exactly in a ASP.NET Web Tool and these works. Copy from Left (Source) to Right (Target) Server. Advantage is, that is automatically registered and usable on the Target server.

When you more help then let it know.
Hi,

I think that is exactly what I have in mind as a long-term goal. If possible as a web application.
So little time - so many things you could "build".

Best regards,
orlando
User avatar
orlando
Community Contributor
Posts: 167
Joined: Fri Aug 04, 2017 8:27 am
OLAP Product: TM1
Version: PAL 2.0.8
Excel Version: Office 365

Re: Register process via RestAPI

Post by orlando »

Wim Gielis wrote: Sat Apr 10, 2021 2:27 pm Hi,

I haven't experimented with it (yet) but would be PAFE API be an alternative ? In the end it's VBA so not terribly difficult (I assume :-) )

There's code here: https://ibm.github.io/paxapi/#rest-api
and now in english :lol:
Hi,

could be. I'll take a closer look.

Best regards
orlando
Last edited by orlando on Thu Apr 15, 2021 11:54 am, edited 1 time in total.
lotsaram
MVP
Posts: 3651
Joined: Fri Mar 13, 2009 11:14 am
OLAP Product: TableManager1
Version: PA 2.0.x
Excel Version: Office 365
Location: Switzerland

Re: Register process via RestAPI

Post by lotsaram »

Rest API is much better tested, more complete and more stable than PAfE API. Best bet is to use Rest API via VBA. There will be a bit of effort in parsing MDX and transforming json response to tabular format but way less headaches overall.
Please place all requests for help in a public thread. I will not answer PMs requesting assistance.
Post Reply