Blocworx API
  • Welcome!
  • Quick Start
  • Reference
    • API Reference
      • Getting Data
      • Getting Reports
      • Updating Data
      • Adding Data
Powered by GitBook
On this page
  • Adding Data
  • Adds Data to Blocworx
  1. Reference
  2. API Reference

Adding Data

Adding Data

Adds Data to Blocworx

POST https://example.mydomain.com/api/add-data

Request Body

Name
Type
Description

scanStationID*

integer

The ID of the bloc you want to add data to. This is the last number in the URL of the bloc, in this example it is 1234: https://example.mydomain.com/module/module-name/bloc/1234

jobID

integer

The ID of the module

dataToAdd

object

A json object of data to add

{"returnedStationID":123456}
{
    "error": "You are not authorized to access this bloc"
}
{
    "error": [ERROR MESSAGE HERE]
}
<?php

$url = "https://subdomain.blocworx.com/api/add-data";
$token = "[AUTHTOKEN]";

$postFields = [
    'scanStationID' => '7603',
    'jobID' => '1304',
    'dataToAdd' => '{"field_1":"Test","another_one":"test","last_one":"testing 12"}',
];

$ch = curl_init($url);

curl_setopt($ch, CURLOPT_RETURNTRANSFER, true);
curl_setopt($ch, CURLOPT_POST, true);
curl_setopt($ch, CURLOPT_POSTFIELDS, $postFields);
curl_setopt($ch, CURLOPT_HTTPHEADER, [
    "Content-Type: multipart/form-data",
    "Authorization: Bearer {$token}"
]);

$response = curl_exec($ch);

if (curl_errno($ch)) {
    echo 'Error: ' . curl_error($ch);
} else {
    echo 'Response: ' . $response;
}

curl_close($ch);
   const url = "https://subdomain.blocworx.com/api/add-data";
      const token = "[AUTHTOKEN]";
      const postData = {
        'scanStationID': '7603',
        'jobID': '1304',
        'dataToAdd': '{"field_1":"Test","another_one":"test","last_one":"testing 12"}',
      };

      $.ajax({
        url: url,
        type: 'POST',
        data: postData,
        headers: {
          "Content-Type": "multipart/form-data",
          "Authorization": "Bearer " + token
        },
        success: function(response) {
          console.log("Response:", response);
        },
        error: function(jqXHR, textStatus, errorThrown) {
          console.error("Error:", textStatus, errorThrown);
        }
      });
    });
const axios = require('axios');
const FormData = require('form-data');

const url = 'https://subdomain.blocworx.com/api/add-data';
const token = '[AUTHTOKEN]';

const data = new FormData();
data.append('scanStationID', '7603');
data.append('jobID', '1304');
data.append('dataToAdd', '{"field_1":"Test","another_one":"test","last_one":"testing 12"}');

const headers = {
  ...data.getHeaders(),
  'Authorization': `Bearer ${token}`,
};

axios.post(url, data, { headers: headers })
  .then(response => {
    console.log('Response:', response.data);
  })
  .catch(error => {
    console.error('Error:', error);
  });
import requests

url = "https://subdomain.blocworx.com/api/add-data"
token = "[AUTHTOKEN]"

post_fields = {
    'scanStationID': '7603',
    'jobID': '1304',
    'dataToAdd': '{"field_1":"Test","another_one":"test","last_one":"testing 12"}',
}

headers = {
    "Content-Type": "multipart/form-data",
    "Authorization": f"Bearer {token}",
}

response = requests.post(url, data=post_fields, headers=headers)

if response.status_code != 200:
    print(f"Error: {response.status_code} - {response.text}")
else:
    print(f"Response: {response.text}")
PreviousUpdating Data

Last updated 2 years ago