Skip to main content

Tutorials

Tutorials for the JSON to external table transform method

Abstract

tutorials for the JSON to external table transform method

Requirements:

Complete the tutorial requirements before this procedure.

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

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

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

    {
        "api": "hub",
        "action": "createTransform",
        "authToken": "AuthorizedToken",
        "params": {
            "transformName": "TestTransform2",
            "transformActions": [
                {
                    "inputFields": [
                        "In1"
                    ],
                    "outputFields": [
                        "Out1",
                        "Out2"
                    ],
                    "transformActionName": "jsonToDifferentTableFields",
                    "transformParams": {
                        "targetDatabaseName": "faircom",
                        "targetTableName": "test_out2",
                                            "mapOfPropertiesToFields": [
                            {
                                "propertyPath": "out1",
                                "name": "out1",
                                "type": "VARCHAR",
                                "length": 200
                            },
                            {
                                "propertyPath": "out2",
                                "name": "out2",
                                "type": "DOUBLE"
                            }
                    ]
                    }
                }
            ]
        }
    }
    
  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 for more information about an error.

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

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

  3. Replace the "params" property values with the following "params" values:

    {
        "api": "hub",
        "action": "createIntegrationTable",
        "authToken": "AuthorizedToken",
        "params": {
            "databaseName": "faircom",
            "tableName": "test2",
            "fields": [
                {
                    "name": "In1",
                    "type": "JSON",
                    "length": 100
                }
            ],
            "transformName": "TestTransform2"
        },
        "requestId": "00000006"
    }
  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 for more information about an error.

  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:

    {
        "api": "db",
        "action": "insertRecords",
         "authToken": "AuthorizedToken",
        "params": {
            "tableName": "test2",
            "dataFormat": "arrays",
            "databaseName": "faircom",
            "fieldNames": [
                "In1"
            ],
            "sourceData": [
                [
                    {
                        "out1": "Text data 1.",
                        "out2": 1
                    }],
                    [{
                        "out1": "Text data 2.",
                        "out2": 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 for more information about an error.

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

    Note

    If you do not see test_out2, refresh Tables.

  2. Click the Table Records tab.

  3. Observe the out1 field's and out2 field's data that was extracted from the newly-added JSON object created in Create a transform.