Skip to main content

Table to JSON tutorials

The tutorials in this section show how to take new records that are added to an integration table, transform them into JSON, and store that JSON in another table.

Requirements:

Complete the tutorial requirements before this procedure.

  1. Select DB API from the Select API dropdown menu (see ???).

  2. Select "createDatabase" from the JSON Actions dropdown menu.

  3. Replace the JSON in the API Request editor with the following JSON:

    {
        "api": "hub",
        "authToken": "AuthorizedToken",
        "action": "createTransform",
        "params": {
            "transformName": "TestTransform1",
            "transformActions": [
                {
                    "inputFields": [
                        "In1", "In2"
                    ],
                    "outputFields": [
                        "Out1"
                    ],
                    "transformActionName": "tableFieldsToJson",
                    "transformParams": {}
                }
            ]
        }
    }
    
    
  4. Click Apply defaults to JSON request (Apply.PNG) to replace the "authToken" with a valid token from your session.

  5. Click Send request (Runbutton.png).

  6. Observe the response and ensure the action completed successfully.

    Note

    "errorCode" with a value of 0 indicates success. "errorCode" with a non-zero value indicates a failure, see Errors and contact FairCom with any questions.

Complete the tutorial requirements before this procedure.

  1. Select HUB API from the Select API dropdown menu.

  2. Select "createIntegrationTable" from the JSON Actions dropdown menu.

  3. Replace the JSON in the API Request editor with the following JSON:

    {
        "api": "hub",
        "authToken": "AuthorizedToken",
        "action": "createIntegrationTable",
        "params": {
            "databaseName": "faircom",
            "tableName": "test1",
            "fields": [
            {
                "name": "In1",
                "type": "VARCHAR",
                "length": 100
            },
            {
                "name": "In2",
                "type": "INTEGER"        },
            {
                "name": "Out1",
                "type": "VARCHAR",
                "length": 200
            }],
            "transformName": "TestTransform1"
        }
    }
    
  4. Click Apply defaults to JSON request (Apply.PNG) to replace the "authToken" with a valid token from your session.

  5. Click Send request (Runbutton.png).

  6. Observe the response and ensure the action completed successfully.

    Note

    "errorCode" with a value of 0 indicates success. "errorCode" with a non-zero value indicates a failure, see Errors and contact FairCom with any questions.

  1. Select DB API from the Select API dropdown menu.

  2. Select "insertRecords" from the JSON Actions dropdown menu.

  3. Replace the JSON in the API Request editor with the following JSON:

    {
        "authToken": "AuthorizedToken",
        "api": "db",
        "action": "insertRecords",
        "params": {
            "tableName": "test1",
            "dataFormat": "arrays",
            "databaseName": "faircom",
            "fieldNames": [
                "In1",
                "In2"
            ],
            "sourceData": [
                [
                    "Text data 1",
                    1
                ],
                [
                    "Text data 2",
                    2
                ]
            ]
        }
    }
    
  4. Click Apply defaults to JSON request (Apply.PNG) to replace the "authToken" with a valid token from your session.

  5. Click Send request (Runbutton.png).

  6. Observe the response and ensure the action completed successfully.

    Note

    "errorCode" with a value of 0 indicates success. "errorCode" with a non-zero value indicates a failure, see Errors and contact FairCom with any questions.

  1. Navigate to and select test1 in the Server navigation window through faircom>admin>Tables.

  2. Click the Table Records tab.

  3. Observe the columns and data that the transform created and stored by using the horizontal scrollbar.

    Note

    The in1 and in2 fields show the inserted data fields. The out1 field shows the data from in1 and in2 but is transformed to JSON.