Planning Analytics

Planning Analytics

Get AI-infused integrated business planning

 View Only
  • 1.  Using REST with PAX API in Cloud

    Posted 10/10/19 02:13 PM
    I've been experimenting with the PAX API lately and one feature I think has lots of promise is the use of the REST API component.  Especially if I need/want to query for running processes or may some other custom function.

    However, when I try the sample code I get a 404 error when trying to execute a REST query against a PA Cloud instance.  Before trying the REST command I log into the server I'd like to connect using the PAX Add-In, and while I'm debugging I see that it's correctly identifying the server.  It's just that when it executes a query it gives me a 404 error.

    Are there any issues using the REST API component of the PAX API when connecting to a PA Cloud instance?  At this point I'm just trying a basic query.  

    Thanks,

    ------------------------------
    Wayne
    ------------------------------

    #PlanningAnalyticswithWatson


  • 2.  RE: Using REST with PAX API in Cloud

    Posted 10/11/19 11:26 AM
    Hi Wayne.  404 suggests the URL is invalid.  What does the query look like that you are trying to execute?  The tm1 server name is case sensitive, are you sure what you are sending matches?  Are you using a non-interactive account to authenticate?


    https://www.ibm.com/support/knowledgecenter/en/SSD29G_2.0.0/com.ibm.swg.ba.cognos.tm1_cloud_mg.2.0.0.doc/c_tm1_cloud_techitem_access_restapi.html

    ------------------------------
    Tim Fischer
    ------------------------------



  • 3.  RE: Using REST with PAX API in Cloud

    Posted 10/14/19 09:36 AM
    If you could provide a sample, we may be able to give some more direct advice.

    You should be able to post to the ExecuteMDX action with the query payload, and PA for Excel's REST api VBA facility should help with any processing of the JSON reply on a successful call.

    404 implies more that the uri component of the vba call was incorrect, as Tim said.

    ------------------------------
    Ted Phillips
    ------------------------------



  • 4.  RE: Using REST with PAX API in Cloud

    Posted 10/15/19 12:29 AM
    Apologies it took some time to reply.

    This is the code that I'm using... it's a modified copy and paste of the IBM PAX API code (https://ibm.github.io/paxapi/#rest-api)

    Public Property Get OData(Server As String) As String
        'OData endpoint
        OData = HubEndpoint + "server('" + Server + "')/api/v1"
    End Property
    
    Public Property Get Current() As String
        Current = Reporting.Settings.GetValue("MruServer")
    End Property
    
    Public Function GetCurrentServer() As String
       Dim sServerCubeMRU As String
       Dim sServerCube As Variant
       Dim sServer As String
       sServerCubeMRU = Reporting.Settings.GetValue("MruPackage")
       sServerCubeMRU = Mid(sServerCubeMRU, 2, Len(sServerCubeMRU) - 2)
       sServerCube = Split(sServerCubeMRU, ",")
       sServer = Split(sServerCube(0), ":")(1)
       GetCurrentServer = Mid(sServer, 3, Len(sServer) - 3)
    End Function
    
    Public Function oDataGet(path As String) As String
    'Public Function oDataGet(path As String) As JSONObjectWrapper
        'Dim result As New JSONParser
        'Dim response As Object
        Dim response As String
        Dim theConnection As Object
        Set theConnection = Reporting.getConnection(Current)
        response = Reporting.getConnection(Current).Get(OData(GetCurrentServer) & "/" & path)
        MsgBox (response)
    End Function
    Public Sub doGetThreads()
        Dim aWrapper As String
        aWrapper = oDataGet("")
    End Sub
    
    

    When I step through the code it resolves the server correctly but when it retrieves the response it returns the 404 error.  This is just a test at this point.  I'm trying to simulate a REST call that I'm able to successfully perform.  I'm not including any wrappers, etc...  I just want a response, which I'm not getting.  My expectation is that this would be similar to https://[SERVER].planning-analytics.ibmcloud.com/tm1/api/

    ------------------------------
    Wayne
    ------------------------------



  • 5.  RE: Using REST with PAX API in Cloud

    Posted 10/16/19 09:16 AM
    Hi Wayne,

    I think the sample in the documentation is a tad outdated (read: I, preparing for a Hands-on Lab, noticed my samples didn't work any longer either).
    The path to the TM1 server's REST resources has changed which, in your sample, can be fixed by changing the OData property (a very poorly chosen name for this property function IMHO) in:
    OData = "tm1/" + Server + "/api/v1"​
    That fixed this issue for me.

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



  • 6.  RE: Using REST with PAX API in Cloud

    Posted 10/16/19 09:39 AM
    Excellent, after changing my code to this...

    Public Property Get HubEndpoint() As String
        'Endpoint that CAFE connects to
        HubEndpoint = "pmhub/pm/tm1/"
    End Property
    
    Public Property Get OData(Server As String) As String
        'OData endpoint
        OData = "tm1/" + Server + "/api/v1"
    End Property
    
    Public Property Get Current() As String
        Current = Reporting.Settings.GetValue("MruServer")
    End Property
    
    Public Function GetCurrentServer() As String
       Dim sServerCubeMRU As String
       Dim sServerCube As Variant
       Dim sServer As String
       sServerCubeMRU = Reporting.Settings.GetValue("MruPackage")
       sServerCubeMRU = Mid(sServerCubeMRU, 2, Len(sServerCubeMRU) - 2)
       sServerCube = Split(sServerCubeMRU, ",")
       sServer = Split(sServerCube(0), ":")(1)
       GetCurrentServer = Mid(sServer, 3, Len(sServer) - 3)
    End Function
    
    Public Function oDataGet(path As String) As String
    'Public Function oDataGet(path As String) As JSONObjectWrapper
        'Dim result As New JSONParser
        'Dim response As Object
        Dim response As String
        Dim theConnection As Object
        Set theConnection = Reporting.getConnection(Current)
        response = Reporting.getConnection(Current).Get(OData(GetCurrentServer) & "/" & path).toString()
        MsgBox (response)
    End Function
    Public Sub doGetThreads()
        Dim aWrapper As String
        aWrapper = oDataGet("")
    End Sub
    
    ​


    I received the following pop-up...

    XML from IBM PA PAX

    … which is what I was expecting.  Now that I can connect using the REST API I should be able to muddle my way through to do what I'm hoping using the IBM PAX API.

    Thanks,

    ------------------------------
    Wayne
    ------------------------------