Page 1 of 1

Register process via RestAPI

Posted: Wed Apr 07, 2021 9:55 am
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

Re: Register process via RestAPI

Posted: Thu Apr 08, 2021 7:55 am
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?

Re: Register process via RestAPI

Posted: Thu Apr 08, 2021 7:19 pm
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...

Re: Register process via RestAPI

Posted: Thu Apr 08, 2021 8:31 pm
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.

Re: Register process via RestAPI

Posted: Fri Apr 09, 2021 7:11 am
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

Re: Register process via RestAPI

Posted: Fri Apr 09, 2021 7:14 am
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

Re: Register process via RestAPI

Posted: Fri Apr 09, 2021 7:18 am
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

Re: Register process via RestAPI

Posted: Fri Apr 09, 2021 12:31 pm
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

Re: Register process via RestAPI

Posted: Fri Apr 09, 2021 3:12 pm
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.

Re: Register process via RestAPI

Posted: Fri Apr 09, 2021 3:18 pm
by Elessar
hI,

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

Re: Register process via RestAPI

Posted: Fri Apr 09, 2021 4:06 pm
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.

Re: Register process via RestAPI

Posted: Sat Apr 10, 2021 2:27 pm
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

Re: Register process via RestAPI

Posted: Thu Apr 15, 2021 7:19 am
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

Re: Register process via RestAPI

Posted: Thu Apr 15, 2021 7:21 am
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

Re: Register process via RestAPI

Posted: Thu Apr 15, 2021 8:23 am
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.