PAX REST API

Post Reply
Dimix
Posts: 32
Joined: Fri Jan 15, 2016 2:53 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

PAX REST API

Post by Dimix »

Hi Gurus!

Struggling a bit to get the PAX REST API to work. Below is the syntax for the GET request, but I can't find any references (in the documentation, or on the web) to JSONObjectWrapper or JSONParser. Where can I find these, do you know?

Public Function oDataGet(path As String) As JSONObjectWrapper
Dim result As New JSONParser
Dim response As Object
Set response = Reporting.GetConnection(Current).Get(OData(GetCurrentServer) & "/" & path)
End Function

This is the PAX REST API documentation I have found:
https://ibm.github.io/paxapi/#get-requests
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: PAX REST API

Post by macsir »

Good to know this new VBA functions exist. I am interested in testing this later.
In TM1,the answer is always yes though sometimes with a but....
http://tm1sir.blogspot.com.au/
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: PAX REST API

Post by macsir »

Dimix wrote: Wed Feb 27, 2019 11:38 am Hi Gurus!

Struggling a bit to get the PAX REST API to work. Below is the syntax for the GET request, but I can't find any references (in the documentation, or on the web) to JSONObjectWrapper or JSONParser. Where can I find these, do you know?

Public Function oDataGet(path As String) As JSONObjectWrapper
Dim result As New JSONParser
Dim response As Object
Set response = Reporting.GetConnection(Current).Get(OData(GetCurrentServer) & "/" & path)
End Function

This is the PAX REST API documentation I have found:
https://ibm.github.io/paxapi/#get-requests
Hi, Dimix
Don't worry about JSONObjectWrapper and JSONParser functions. They are just dummy place holders which haven't been implemented actually here.
You can borrow third-party tools to parse JSON results, e.g. https://github.com/VBA-tools/VBA-JSON.
Basically, I put all of them into VBA modules, and get the response as the snapshot below. From here, you can parse JSON response and transfer them into excel values.
testpaxapi.PNG
testpaxapi.PNG (36.83 KiB) Viewed 3851 times
In TM1,the answer is always yes though sometimes with a but....
http://tm1sir.blogspot.com.au/
Dimix
Posts: 32
Joined: Fri Jan 15, 2016 2:53 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: PAX REST API

Post by Dimix »

Thanks macsir!

Will give it a try later today.
Dimix
Posts: 32
Joined: Fri Jan 15, 2016 2:53 pm
OLAP Product: TM1
Version: 10.2.2
Excel Version: 2013

Re: PAX REST API

Post by Dimix »

Thanks again macsir, I'm getting closer. :)

The Get and Delete request works, but I'm struggling a bit with Post, getting an error message. The documentation talks about 'payload', as 'The JSON payload that you are storing or updating to the TM1 Server'. What does it mean, is it maybe the same as Body?

The Post request:
Set response = Reporting.GetConnection(Current).Post(OData(GetCurrentServer) & "/" & path, payload)

My syntax that gives me an error:
sBody = "{""Name"": ""New Element"",""Type"": ""String""}"
Set response = Reporting.GetConnection(Current).Post(OData(GetCurrentServer) & "/Dimensions('plan_business_unit')/Hierarchies('plan_business_unit')/Elements", sBody)

When I execute this, I get an error:
{ "error" : { "code" : "248", "message" : "inflate error: CODE: -3 MSG: incorrect header check"}}

Can you see any obvious mistakes from my side?
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: PAX REST API

Post by macsir »

Hi,
Good to know. Yes, I suspect that you can't use double quotes to escape double quotes in json string. I didn't test but reading from google, you could try to use chr(34) to replace it.
e.g,
String = "This is the Test only." & chr(34) & "double ok" & chr(34) & "."
In TM1,the answer is always yes though sometimes with a but....
http://tm1sir.blogspot.com.au/
Post Reply