Skip to content

API Examples

Base URL examples below use:

http://localhost:8081

GET /sortation

curl -i "http://localhost:8081/sortation?timeOut=10"
const res = await fetch("http://localhost:8081/sortation?timeOut=10");
if (res.status === 204) return;
const data = await res.json();
console.log(res.status, data);
import requests

res = requests.get("http://localhost:8081/sortation", params={"timeOut": 10})
if res.status_code == 204:
    pass
else:
    print(res.status_code, res.json())
using var client = new HttpClient();
var response = await client.GetAsync("http://localhost:8081/sortation?timeOut=10");

if (response.StatusCode == System.Net.HttpStatusCode.NoContent)
{
    return;
}

var body = await response.Content.ReadAsStringAsync();
Console.WriteLine($"{(int)response.StatusCode} {body}");

POST /sortation

curl -i -X POST "http://localhost:8081/sortation" \
  -H "Content-Type: application/json" \
  -d '{"TrackID":"00.329.000092727","Destination":"DST-CH-0012-1-B","Barcode":"B000121238776"}'
const payload = {
  TrackID: "00.329.000092727",
  Destination: "DST-CH-0012-1-B",
  Barcode: "B000121238776"
};

const res = await fetch("http://localhost:8081/sortation", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload)
});

console.log(res.status, await res.json());
import requests

payload = {
    "TrackID": "00.329.000092727",
    "Destination": "DST-CH-0012-1-B",
    "Barcode": "B000121238776"
}

res = requests.post("http://localhost:8081/sortation", json=payload)
print(res.status_code, res.json())
using System.Text;
using System.Text.Json;

using var client = new HttpClient();
var payload = new
{
    TrackID = "00.329.000092727",
    Destination = "DST-CH-0012-1-B",
    Barcode = "B000121238776"
};

var content = new StringContent(
    JsonSerializer.Serialize(payload),
    Encoding.UTF8,
    "application/json");

var response = await client.PostAsync("http://localhost:8081/sortation", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());

GET /destination

curl -i "http://localhost:8081/destination?timeOut=10"
const res = await fetch("http://localhost:8081/destination?timeOut=10");
if (res.status === 204) return;
const data = await res.json();
console.log(res.status, data);
import requests

res = requests.get("http://localhost:8081/destination", params={"timeOut": 10})
if res.status_code != 204:
    print(res.status_code, res.json())
using var client = new HttpClient();
var response = await client.GetAsync("http://localhost:8081/destination?timeOut=10");

if (response.StatusCode != System.Net.HttpStatusCode.NoContent)
{
    Console.WriteLine(await response.Content.ReadAsStringAsync());
}

POST /destination

curl -i -X POST "http://localhost:8081/destination" \
  -H "Content-Type: application/json" \
  -d '{"Destination":"DST-CH-0012-1-B","DestinationStatus":"NotReady","DestinationText":"SORT","LightStatus":"Solid","LightColor":"BLUE"}'
const payload = {
  Destination: "DST-CH-0012-1-B",
  DestinationStatus: "NotReady",
  DestinationText: "SORT",
  LightStatus: "Solid",
  LightColor: "BLUE"
};

const res = await fetch("http://localhost:8081/destination", {
  method: "POST",
  headers: { "Content-Type": "application/json" },
  body: JSON.stringify(payload)
});

console.log(res.status, await res.json());
import requests

payload = {
    "Destination": "DST-CH-0012-1-B",
    "DestinationStatus": "NotReady",
    "DestinationText": "SORT",
    "LightStatus": "Solid",
    "LightColor": "BLUE"
}

res = requests.post("http://localhost:8081/destination", json=payload)
print(res.status_code, res.json())
using System.Text;
using System.Text.Json;

using var client = new HttpClient();
var payload = new
{
    Destination = "DST-CH-0012-1-B",
    DestinationStatus = "NotReady",
    DestinationText = "SORT",
    LightStatus = "Solid",
    LightColor = "BLUE"
};

var content = new StringContent(
    JsonSerializer.Serialize(payload),
    Encoding.UTF8,
    "application/json");

var response = await client.PostAsync("http://localhost:8081/destination", content);
Console.WriteLine(await response.Content.ReadAsStringAsync());