Skip to main content
insightsoftware Documentation insightsoftware Documentation
{%article.title%}
Published:
Was this article helpful?
0 out of 0 found this helpful

Consuming Other Data Sources

In this section, you can find information on the following topics:

Consuming other data sources via ODBC (Open Database Connectivity) queries

For importing data from a third-party application to a Longview DataArea or DataTable, you may use an ODBC connection. This is accomplished by using a Longview Data Import and specifying ODBC as the DataSource, along with an appropriate connection string and SQL statement to execute.

The following table lists the available Application Framework ImportSpec functions to support ODBC imports in Longview.

For more information, see ImportSpec and ExportSpec Functions in the Longview Developer Guide.

Function

Usage

DataSource ODBC, “Connection String”

Use this function with an import specification to define the source of the data to be imported.

SQLBatchSize

Specify the number of records to retrieve with each fetch against the ODBC data source

SQLStatement

Specify the SQL statement to pass along to the ODBC data source

Example of using ODBC in an ImportSpec document

DataSource ODBC, "Driver={SQL Server Native Client 10.0};Server=ca127MyServer;Database=MYDB;Trusted_Connection=Yes;"

SQLBatchSize 10

SQLStatement “SELECT [Currency], [Rate] FROM FXRates”

Consuming other data sources by calling REST APIs

REST APIs enable organizations to communicate with each other and with clients, without deep knowledge of each other’s IT systems. The REST API provider defines a format for requests for each of its services and the response that the service generates.

Longview Application Framework can call REST APIs provided by third-party applications using various commands in a Procedure document. These commands will execute the third-party REST APIs using the provider’s defined format and retrieve the responses from the Provider in a defined format. A popular return format for REST APIs is JSON format, which is a lightweight, open-standard, object-oriented format that is easy for humans to read. When an API returns JSON format, Longview Application Framework can translate the response directly into an object. However, Longview Application Framework supports results in other formats as well. Options for handling responses include:

  • using a STRING variable as the result target and processing that string in memory or exporting the result, using EXPORTVARIABLE, to a file.
  • using an OBJECT variable as the result target and processing that object in memory or writing to a file via EXPORTVARIABLE.
  • using a DOCUMENT as the result target and saving the resulting document to a file using SAVE. This method is useful, for example, with csv responses.

The following table lists the available Application Framework Procedure commands to support consuming REST APIs in Longview. For more information, see the Longview Developer Guide.

Command

Usage

Rest DeleteRequestHeader

Delete a header and its value that was previously set using REST SETREQUESTHEADER

Rest ExecuteDelete

Delete a resource identified by a URI

Rest ExecuteGet

Retrieve information returned from a REST http GET method

Rest ExecutePost

Post to a resource using a restful http POST method

Rest ExecutePut

Put or update data to a resource using a restful http PUT method

Rest GetResponseHeader

Retrieve a specified response header for the REST EXECUTEGET, REST EXECUTEPOST, or REST EXECUTEPUT command that was previously invoked

Rest GetResponseStatus

Retrieve the http response status for the REST EXECUTEGET, REST EXECUTEPOST, or REST EXECUTEPUT command that was previously invoked

Rest SetRequestHeader

Set a header for the REST call about to be executed

Example of Calling REST APIs in a Procedure document

// Example with Target as a variable

CREATE VARIABLE TestResult1 AS String

REST EXECUTEGET "http://api.fixer.io/latest" TO TestResult1

EXPORTVARIABLE TestResult1 TestResult1.json

 

// Example with Target as a document

CREATE DOCUMENT "TestResult2.json"

REST EXECUTEGET "http://api.fixer.io/latest" TO "TestResult2.json"

SAVE "TestResult2.json"

Published:

Consuming Other Data Sources

In this section, you can find information on the following topics:

Consuming other data sources via ODBC (Open Database Connectivity) queries

For importing data from a third-party application to a Longview DataArea or DataTable, you may use an ODBC connection. This is accomplished by using a Longview Data Import and specifying ODBC as the DataSource, along with an appropriate connection string and SQL statement to execute.

The following table lists the available Application Framework ImportSpec functions to support ODBC imports in Longview.

For more information, see ImportSpec and ExportSpec Functions in the Longview Developer Guide.

Function

Usage

DataSource ODBC, “Connection String”

Use this function with an import specification to define the source of the data to be imported.

SQLBatchSize

Specify the number of records to retrieve with each fetch against the ODBC data source

SQLStatement

Specify the SQL statement to pass along to the ODBC data source

Example of using ODBC in an ImportSpec document

DataSource ODBC, "Driver={SQL Server Native Client 10.0};Server=ca127MyServer;Database=MYDB;Trusted_Connection=Yes;"

SQLBatchSize 10

SQLStatement “SELECT [Currency], [Rate] FROM FXRates”

Consuming other data sources by calling REST APIs

REST APIs enable organizations to communicate with each other and with clients, without deep knowledge of each other’s IT systems. The REST API provider defines a format for requests for each of its services and the response that the service generates.

Longview Application Framework can call REST APIs provided by third-party applications using various commands in a Procedure document. These commands will execute the third-party REST APIs using the provider’s defined format and retrieve the responses from the Provider in a defined format. A popular return format for REST APIs is JSON format, which is a lightweight, open-standard, object-oriented format that is easy for humans to read. When an API returns JSON format, Longview Application Framework can translate the response directly into an object. However, Longview Application Framework supports results in other formats as well. Options for handling responses include:

  • using a STRING variable as the result target and processing that string in memory or exporting the result, using EXPORTVARIABLE, to a file.
  • using an OBJECT variable as the result target and processing that object in memory or writing to a file via EXPORTVARIABLE.
  • using a DOCUMENT as the result target and saving the resulting document to a file using SAVE. This method is useful, for example, with csv responses.

The following table lists the available Application Framework Procedure commands to support consuming REST APIs in Longview. For more information, see the Longview Developer Guide.

Command

Usage

Rest DeleteRequestHeader

Delete a header and its value that was previously set using REST SETREQUESTHEADER

Rest ExecuteDelete

Delete a resource identified by a URI

Rest ExecuteGet

Retrieve information returned from a REST http GET method

Rest ExecutePost

Post to a resource using a restful http POST method

Rest ExecutePut

Put or update data to a resource using a restful http PUT method

Rest GetResponseHeader

Retrieve a specified response header for the REST EXECUTEGET, REST EXECUTEPOST, or REST EXECUTEPUT command that was previously invoked

Rest GetResponseStatus

Retrieve the http response status for the REST EXECUTEGET, REST EXECUTEPOST, or REST EXECUTEPUT command that was previously invoked

Rest SetRequestHeader

Set a header for the REST call about to be executed

Example of Calling REST APIs in a Procedure document

// Example with Target as a variable

CREATE VARIABLE TestResult1 AS String

REST EXECUTEGET "http://api.fixer.io/latest" TO TestResult1

EXPORTVARIABLE TestResult1 TestResult1.json

 

// Example with Target as a document

CREATE DOCUMENT "TestResult2.json"

REST EXECUTEGET "http://api.fixer.io/latest" TO "TestResult2.json"

SAVE "TestResult2.json"

For an optimal Community experience, Please view on Desktop