Please enable JavaScript to view this site.

The manual for the JobRouter developer

For creating and editing JobData contents the following routes are available:

POST /application/jobdata/tables/:guid/datasets create data record

PUT /application/jobdata/tables/:guid/datasets/:jrid modify data record with the delivered ID

The JobDatatable is identified through its GUID (parameter guid).

The return value is complied in JSON format:

{

    "datasets": [

        {

            "jrid": "1",  // Identification column

            "company": "Acme Ltd.",

            "street": "Example street 11",

            "zip_code": "05558",

            "profit_per_year": 12345678.9,

         ... // further column values

        }

    ]

}

Example: Create data record

guzzlehttp

// User has been authenticated already

 

try {

    // Define data record

    $data = [

        'dataset' => [

            'sname' => 'Acme Corp.',

            'sadress' => 'Acme Rd. 12',

            'sdate' => '2017-06-30T13:22:45+01:00',

            'sphone' => '076-343-5226',

            'srating' => 6,

        ],

    ];

 

    // Create data record

    $response = $client->request(

        'POST',

        'application/jobdata/tables/2076E38C-3EC0-234E-EFFD-E15F14879CB1/datasets',

        [

            'json' => $data,

        ]

    );

 

    // Issue response

    echo "Status code: " . $response->getStatusCode() . "\n";

    $body = json_decode($response->getBody(), true);

    echo "Data record ID: " . $body['datasets'][0]['jrid'] . "\n";

} catch (Exception $e) {

    echo "Error during performance: " . $e->getMessage() . "\n";

}

 

// Finish user session

cURL

// User has been authenticated already

 

// Define data record

$data = [

    'dataset' => [

        'sname'  => 'Acme Corp.',

        'sadress' => 'Acme Rd. 12',

        'sdate' => '2017-09-03T13:22:45+01:00',

        'sphone' => '076-343-5226',

        'srating' => 6

    ],

];

 

$headers = [

    'Accept: application/json',

    'Content-Type: application/json',

];

curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $headers);

curl_setopt(

    $curlHandle,

    'http://example.org/jobrouter/api/rest/v2/application/jobdata/' .

    'tables/2076E38C-3EC0-234E-EFFD-E15F14879CB1/datasets'

);

curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curlHandle, CURLOPT_POST, 1);

curl_setopt($curlHandle, CURLOPT_POSTFIELDS, json_encode($data));

curl_setopt($curlHandle, CURLOPT_COOKIEFILE, 'path/to/cooke/file.cookie');

 

// Create data record

$response = curl_exec($curlHandle);

$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);

 

curl_close();

 

if ($statusCode == 200) {

    // Display response

    $data = json_decode($response, true);

    echo "Data record ID: " . $data['datasets'][0]['jrid'] . "\n";

} else {

    echo "Error during performance: Code - " . $statusCode . ", ";

    echo "Response: " . var_export($response, true);

}

 

// Finish user session

Example: Edit data record

guzzlehttp

// User has been authenticated already

 

try {

    // Define data which are modified

    $data = [

        'dataset' => [

            'sphone' => '076-343-3445',

            'srating' => 5

        ],

    ];

 

    $response = $client->request(

        'PUT',

        'application/jobdata/tables/2076E38C-3EC0-234E-EFFD-E15F14879CB1/datasets/12345',

        [

            'json' => $data,

        ]

    );

 

    echo "Status code: " . $response->getStatusCode() . "\n";

    $body = json_decode($response->getBody(), true);

    foreach ($body['datasets'][0] as $columnName => $columnValue) {

        echo $columnName . ": " . $columnValue . "\n";

    }

} catch (Exception $e) {

    echo "Error during performance: " . $e->getMessage() . "\n";

}

 

// Finish user session

cURL

// User has been authenticated alreay

 

// Define data which are modified

$data = [

    'dataset' => [

        'sphone' => '076-343-3445',

        'srating' => 5

    ],

];

 

$headers = [

    'Accept: application/json',

    'Content-Type: application/json',

];

curl_setopt($curlHandle, CURLOPT_HTTPHEADER, $headers);

curl_setopt($curlHandle,

    'http://example.org/jobrouter/api/rest/v2/application/jobdata/' .

    'tables/2076E38C-3EC0-234E-EFFD-E15F14879CB1/datasets/12345');

curl_setopt($curlHandle, CURLOPT_RETURNTRANSFER, true);

curl_setopt($curlHandle, CURLOPT_CUSTOMREQUEST, 'PUT');

curl_setopt($curlHandle, CURLOPT_POSTFIELDS, json_encode($data));

curl_setopt($curlHandle, CURLOPT_COOKIEFILE, 'path/to/cooke/file.cookie');

 

// Create data record

$response = curl_exec($curlHandle);

$statusCode = curl_getinfo($curlHandle, CURLINFO_HTTP_CODE);

 

curl_close();

 

if ($statusCode == 200) {

    // Display response

    $data = json_decode($response, true);

    foreach ($data['datasets'][0] as $columnName => $columnValue) {

        echo $columnName . ": " . $columnValue . "\n";

    }

} else {

    echo "Error during performance: Code - " . $statusCode . ", ";

    echo "Response: " . var_export($response, true);

}

 

// Finish user session