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

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 model file

Use the Driver Files API to upload an input REST model file. REST endpoints must be provided either via the Web UI or by uploading an input REST model file. 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 model file is provided in the form of a JSON object. (Refer to Model file syntax in the Progress DataDirect Autonomous REST Connector for JDBC User's Guide 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 model file

The Driver Files API can be used to retrieve the input REST model 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 model file

The output REST model file is created at the time of the test connection. The output REST model is a JSON file that maps the relational view of the REST endpoints provided in the input REST model file. A review of the output REST model file may be useful for developing an input REST model 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)"
        },
        ...
    }
}