skip to main content
Using Hybrid Data Pipeline : Creating and using REST data sources : Creating REST data sources with the API
  

Try Now

Creating REST data sources with the API

The following operations should be performed to set up and review a REST data source using Hybrid Data Pipeline APIs.
*Create a REST data source
*Upload an input REST file
*Test the REST data source
*Retrieve the input REST file
*Retrieve the output REST file

Create a REST data source

Use the Data Sources API to create a REST data source. The following example creates a REST data source called TestREST. Values for the name, dataStore, connectionType, and options parameters must be specified. All REST data sources are created by way of the Autonomous REST Connector data store with an ID of 62 and with a connection type of Cloud.
Request
POST https://MyServer:8443/api/mgmt/datasources
Request Payload

{
"name": "TestREST",
"dataStore": 62,
"connectionType": "Cloud",
"description": "Test REST ds definition",
"options": {
"User": "test",
"Password": "test",
"ODataVersion": "4",
"AuthenticationMethod": "Basic"
}
}
Response Payload

{
"id": 956,
"name": "TestREST",
"dataStore": 62,
"connectionType": "Cloud",
"description": "Test REST ds definition",
"options": {
"User": "test",
"Password": "test",
"ODataVersion": "4",
"AuthenticationMethod": "Basic"
}
}

Upload an input REST file

Use the Driver Files API to upload an input REST file. REST endpoints must be provided either via the Web UI or by uploading an input REST file must be uploaded. As shown in the following example, the request includes the data source ID that was generated when the data source was created (956). In the request payload, the input REST file is provided in the form of a JSON object. (See Creating an input REST file for syntax requirements.)
Request
POST https://MyServer:8443/api/mgmt/datasources/956/export/driverfiles/inputrest
Request Payload

{
"countries": {
"#path": "http://example.com/country",
"#get": {
"start_date":"2018-08-31",
"end_date":"2018-09-01",
"departments":"[engineering,marketing,sales]",
"tags":"[blue,green,red]"
}
}
}
Response Payload

{
"countries": {
"#path": "http://example.com/country",
"#get": {
"start_date":"2018-08-31",
"end_date":"2018-09-01",
"departments":"[engineering,marketing,sales]",
"tags":"[blue,green,red]"
}
}
}

Test the REST data source

Use the Data Sources API to test REST connectivity. In the following example, values for user and password are specified to allow for basic authentication with the REST service.
Request
POST https://MyServer:8443/api/mgmt/datasources/956/test
Request Payload

{
"user": "test",
"password": "test"
}
Response Payload

{
"success":true
}

Retrieve the input REST file

The Driver Files API can be used to retrieve the input REST file for review.
Request
GET https://MyServer:8443/api/mgmt/datasources/956/export/driverfiles/inputrest
Response Payload

{
"countries": {
"#path": "http://example.com/country",
"#get": {
"start_date":"2018-08-31",
"end_date":"2018-09-01",
"departments":"[engineering,marketing,sales]",
"tags":"[blue,green,red]"
}
}
}

Retrieve the output REST file

The output REST file is created at the time of the test connection. The output REST file is a JSON file that maps the relational view of the REST endpoints provided in the input REST file. A review of the output REST file may be useful for developing an input REST file and creating better SQL queries to run against a REST service.
Request
GET https://MyServer:8443/api/mgmt/datasources/956/export/driverfiles/outputrest
Response Payload
{
"countries": {
"#path": [
"https://example.com/country"
],
"type": "VarChar(64),#key",
"metadata": {
"generated": "BigInt",
"url": "VarChar(184)",
"title": "VarChar(64)",
"status": "Integer",
...
},
"features[1]": {
"type": "VarChar(10)",
"properties": {
"size": "Decimal",
"place": "VarChar(108)",
...
},
"geometry": {
"type": "VarChar(7)",
"coordinates[3]": "Double"
},
"id": "VarChar(27)"
},
...
}
}