Solved

Use Table data in REST API

  • 13 March 2023
  • 1 reply
  • 170 views

Userlevel 3
Badge +1

Hi, 

 

I am wondering if it is at all possible to use data stored in a TimeXtender table as variables in a REST API call. 

I have two use cases that hopefully explain what I am trying to achieve

 

A combination of two REST API's where one requires the output of the other: 

The first one retrieves all possible classes that can be attended, the second one retrieves all people enrolled in such a class. But the class name is a parameter in the header. 

I'd like to store the class names in a table and then loop through them (not sure if that's the way to go) and request all enrolled students.

 

A Machine Learning function

In, for example, Azure Machine Learning Studio I am able to host a model using a REST API. 

Then, I can call the model and by inserting the parameter values I receive a predicted value. I'd like to do this in the data warehouse since it saves time compared to requesting it every time a dashboard reloads. 

But again, I'd need to input values from a TimeXtender table. 

 

Is there a recommended way to approach this using just the TimeXtender toolset (including RSD files)? 

icon

Best answer by Christian Hauggaard 2 May 2023, 16:57

View original

1 reply

Userlevel 6
Badge +5

Hi @sierd.zuiderveld 

I am not sure about using data from a TimeXtender table, however it might be possible to use output from one call as a parameter in a second call. One possible way of doing this is to set the output of the API call to an item that the 2nd call can access. The item you would want to use is either likely _input or _connection depending on if the output from the first call is only needed for calls from the same RSD file or if it is needed across different RSD files. Here is an example of this where the Token value from the response is being set in the _connection item to be referenced in other API calls:

<api:call op="jsonproviderGet" out="response">
    <api:set attr="_connection._token" value="[response.Token]" />
</api:call> 

Then in a later API call you would set the header with something like this:

<api:set attr="Header:Name#" value="Authorization" />
<api:set attr="Header:Value#" value="[_connection._token]" />

This example uses the _connection item, but if you didn't want to save the value outside of the RSD file, you could use _input, or any item you created. Please see documentation on items in RSD scripts here for reference:
CData JDBC Driver for REST - Items in API Script

Reply