Blocworx API
  • Welcome!
  • Quick Start
  • Reference
    • API Reference
      • Getting Data
      • Getting Reports
      • Updating Data
      • Adding Data
Powered by GitBook
On this page
  • Updating Data
  • Updates records that match key/value pairs provided
  1. Reference
  2. API Reference

Updating Data

Updating Data

Updates records that match key/value pairs provided

GET https://example.mydomain.com/api/update-records-by-matching-values

Request Body

Name
Type
Description

blocId*

integer

The ID of the bloc you want to update data in. 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

fieldsToUpdate

object

searchItems

object

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

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => 'https://example.mydomain.com/api/update-records-by-matching-values',
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => '',
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 0,
  CURLOPT_FOLLOWLOCATION => true,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => 'POST',
  CURLOPT_POSTFIELDS =>'{
    "blocId": "1234",
    "fieldsToUpdate" : {
        "employee_name" : "Jane Doe",
        "more_infor" : "More Info"
    },
    "searchItems": {
        "employee_id": "12345"
    }
}',
  CURLOPT_HTTPHEADER => array(
    'Authorization: Bearer [AUTHTOKEN]',
    'Content-Type: application/json'
  ),
));

$response = curl_exec($curl);

curl_close($curl);
echo $response;
var settings = {
  "url": "https://example.mydomain.com/api/update-records-by-matching-values",
  "method": "POST",
  "timeout": 0,
  "headers": {
    "Authorization": "Bearer [AUTHTOKEN]",
    "Content-Type": "application/json"
  },
  "data": JSON.stringify({
    "blocId": "1234",
    "fieldsToUpdate": {
      "employee_name": "Jane Doe",
      "more_infor": "More Info"
    },
    "searchItems": {
      "employee_id": "12345"
    }
  }),
};

$.ajax(settings).done(function (response) {
  console.log(response);
});
var request = require('request');
var options = {
  'method': 'POST',
  'url': 'https://example.mydomain.com/api/update-records-by-matching-values',
  'headers': {
    'Authorization': 'Bearer [AUTHTOKEN]',
    'Content-Type': 'application/json'
  },
  body: JSON.stringify({
    "blocId": "1234",
    "fieldsToUpdate": {
      "employee_name": "Jane Doe",
      "more_infor": "More Info"
    },
    "searchItems": {
      "employee_id": "12345"
    }
  })

};
request(options, function (error, response) {
  if (error) throw new Error(error);
  console.log(response.body);
});
import http.client
import json

conn = http.client.HTTPSConnection("example.mydomain.com")
payload = json.dumps({
  "blocId": "1234",
  "fieldsToUpdate": {
    "employee_name": "Jane Doe",
    "more_infor": "More Info"
  },
  "searchItems": {
    "employee_id": "12345"
  }
})
headers = {
  'Authorization': 'Bearer [AUTHTOKEN]',
  'Content-Type': 'application/json'
}
conn.request("POST", "/api/update-records-by-matching-values", payload, headers)
res = conn.getresponse()
data = res.read()
print(data.decode("utf-8"))
PreviousGetting ReportsNextAdding Data

Last updated 2 years ago

The and their values you want to update. { "employee_name" : "Jane Doe", "a_different_field" : "More Data" }

The and their values that need to match to find records to update. { "employee_id" : "5830"}

field slugs
field slugs