Page 1 of 1

PAX REST API

Posted: Wed Feb 27, 2019 11:38 am
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

Re: PAX REST API

Posted: Wed Feb 27, 2019 9:33 pm
by macsir
Good to know this new VBA functions exist. I am interested in testing this later.

Re: PAX REST API

Posted: Thu Feb 28, 2019 12:00 am
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 3874 times

Re: PAX REST API

Posted: Thu Feb 28, 2019 8:47 am
by Dimix
Thanks macsir!

Will give it a try later today.

Re: PAX REST API

Posted: Wed Mar 06, 2019 11:48 am
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?

Re: PAX REST API

Posted: Thu Mar 07, 2019 8:38 pm
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) & "."