Language

POST - Batch data upload

https://testing.hubat.net/api/v2/data-batch

Sending multiple records to the HAT simultaneously, potentially for separate “endpoints” as well as linked, all in one call

Headers

Content-Type

application/json

X-Auth-Token

Body



[
    {
    "endpoint": "rumpel/notable",
    "data": {
        "id": 84995,
        "lastUpdated": "2017-04-23T14:21:51+01:00",
        "data": {
          "notablesv1": {
            "authorv1": {
              "phata": "testing.hubat.net"
            },
            "created_time": "2017-04-10T14:19:59:+01:00",
            "shared": "true",
            "shared_on": "twitter",
            "message": "Showcasing the new HAT APIs",
            "public_until": "2017-05-11T14:21:54+01:00",
            "updated_time": "2017-04-23T14:21:58+01:00",
            "kind": "note"
          }
        }
    },
    "links": [
        {
            "endpoint": "rumpel/nudge",
            "data": {
                "type": "time",
                "nudge": "Share APIs with the world",
                "time": "2017-04-30T14:22:52+01:00"
            }
        }
    ]
    }
]

curl --request POST \
  --url https:///api/v2/data-batch \
  --header 'content-type: application/json' \
  --header 'x-auth-token: ' \
  --data '[{"endpoint":"rumpel/notable","data":{"id":84995,"lastUpdated":"2017-04-23T14:21:51+01:00","data":{"notablesv1":{"authorv1":{"phata":"testing.hubat.net"},"created_time":"2017-04-10T14:19:59:+01:00","shared":"true","shared_on":"twitter","message":"Showcasing the new HAT APIs","public_until":"2017-05-11T14:21:54+01:00","updated_time":"2017-04-23T14:21:58+01:00","kind":"note"}}},"links":[{"endpoint":"rumpel/nudge","data":{"type":"time","nudge":"Share APIs with the world","time":"2017-04-30T14:22:52+01:00"}}]}]'
var data = JSON.stringify([
  {
    "endpoint": "rumpel/notable",
    "data": {
      "id": 84995,
      "lastUpdated": "2017-04-23T14:21:51+01:00",
      "data": {
        "notablesv1": {
          "authorv1": {
            "phata": "testing.hubat.net"
          },
          "created_time": "2017-04-10T14:19:59:+01:00",
          "shared": "true",
          "shared_on": "twitter",
          "message": "Showcasing the new HAT APIs",
          "public_until": "2017-05-11T14:21:54+01:00",
          "updated_time": "2017-04-23T14:21:58+01:00",
          "kind": "note"
        }
      }
    },
    "links": [
      {
        "endpoint": "rumpel/nudge",
        "data": {
          "type": "time",
          "nudge": "Share APIs with the world",
          "time": "2017-04-30T14:22:52+01:00"
        }
      }
    ]
  }
]);

var xhr = new XMLHttpRequest();
xhr.withCredentials = true;

xhr.addEventListener("readystatechange", function () {
  if (this.readyState === this.DONE) {
    console.log(this.responseText);
  }
});

xhr.open("POST", "https:///api/v2/data-batch");
xhr.setRequestHeader("content-type", "application/json");
xhr.setRequestHeader("x-auth-token", "");

xhr.send(data);
<?php

$curl = curl_init();

curl_setopt_array($curl, array(
  CURLOPT_URL => "https:///api/v2/data-batch",
  CURLOPT_RETURNTRANSFER => true,
  CURLOPT_ENCODING => "",
  CURLOPT_MAXREDIRS => 10,
  CURLOPT_TIMEOUT => 30,
  CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
  CURLOPT_CUSTOMREQUEST => "POST",
  CURLOPT_POSTFIELDS => "[{\"endpoint\":\"rumpel/notable\",\"data\":{\"id\":84995,\"lastUpdated\":\"2017-04-23T14:21:51+01:00\",\"data\":{\"notablesv1\":{\"authorv1\":{\"phata\":\"testing.hubat.net\"},\"created_time\":\"2017-04-10T14:19:59:+01:00\",\"shared\":\"true\",\"shared_on\":\"twitter\",\"message\":\"Showcasing the new HAT APIs\",\"public_until\":\"2017-05-11T14:21:54+01:00\",\"updated_time\":\"2017-04-23T14:21:58+01:00\",\"kind\":\"note\"}}},\"links\":[{\"endpoint\":\"rumpel/nudge\",\"data\":{\"type\":\"time\",\"nudge\":\"Share APIs with the world\",\"time\":\"2017-04-30T14:22:52+01:00\"}}]}]",
  CURLOPT_HTTPHEADER => array(
    "content-type: application/json",
    "x-auth-token: "
  ),
));

$response = curl_exec($curl);
$err = curl_error($curl);

curl_close($curl);

if ($err) {
  echo "cURL Error #:" . $err;
} else {
  echo $response;
}
import requests

url = "https:///api/v2/data-batch"

payload = "[{\"endpoint\":\"rumpel/notable\",\"data\":{\"id\":84995,\"lastUpdated\":\"2017-04-23T14:21:51+01:00\",\"data\":{\"notablesv1\":{\"authorv1\":{\"phata\":\"testing.hubat.net\"},\"created_time\":\"2017-04-10T14:19:59:+01:00\",\"shared\":\"true\",\"shared_on\":\"twitter\",\"message\":\"Showcasing the new HAT APIs\",\"public_until\":\"2017-05-11T14:21:54+01:00\",\"updated_time\":\"2017-04-23T14:21:58+01:00\",\"kind\":\"note\"}}},\"links\":[{\"endpoint\":\"rumpel/nudge\",\"data\":{\"type\":\"time\",\"nudge\":\"Share APIs with the world\",\"time\":\"2017-04-30T14:22:52+01:00\"}}]}]"
headers = {
    'content-type': "application/json",
    'x-auth-token': ""
    }

response = requests.request("POST", url, data=payload, headers=headers)

print(response.text)
require 'uri'
require 'net/http'

url = URI("https:///api/v2/data-batch")

http = Net::HTTP.new(url.host, url.port)
http.use_ssl = true
http.verify_mode = OpenSSL::SSL::VERIFY_NONE

request = Net::HTTP::Post.new(url)
request["content-type"] = 'application/json'
request["x-auth-token"] = ''
request.body = "[{\"endpoint\":\"rumpel/notable\",\"data\":{\"id\":84995,\"lastUpdated\":\"2017-04-23T14:21:51+01:00\",\"data\":{\"notablesv1\":{\"authorv1\":{\"phata\":\"testing.hubat.net\"},\"created_time\":\"2017-04-10T14:19:59:+01:00\",\"shared\":\"true\",\"shared_on\":\"twitter\",\"message\":\"Showcasing the new HAT APIs\",\"public_until\":\"2017-05-11T14:21:54+01:00\",\"updated_time\":\"2017-04-23T14:21:58+01:00\",\"kind\":\"note\"}}},\"links\":[{\"endpoint\":\"rumpel/nudge\",\"data\":{\"type\":\"time\",\"nudge\":\"Share APIs with the world\",\"time\":\"2017-04-30T14:22:52+01:00\"}}]}]"

response = http.request(request)
puts response.read_body