GET /web-annotation
/web-annotationReturns a spec-compliant W3C Web Annotation object: `id` present, `body` is a TextualBody object, `motivation` is from the standard vocabulary, `target` is a URI string. Counterpart to /web-annotation, which ships one of four violations.
expect: 200 OK with Content-Type: application/ld+json. Body is a valid Web Annotation with all required fields and no spec violations.
curl -si 'https://not.catastrophic.io/web-annotation' | grep -E '^(HTTP|content-type|x-chaos)'
import urllib.request, json
resp = urllib.request.urlopen("https://not.catastrophic.io/web-annotation")
print("Content-Type:", resp.headers.get("Content-Type"))
print("X-Chaos-Web-Annotation-Mode:", resp.headers.get("X-Chaos-Web-Annotation-Mode"))
body = json.loads(resp.read())
print("id present:", "id" in body)
print("motivation:", body.get("motivation"))
print("body type:", type(body.get("body")).__name__)
print("target type:", type(body.get("target")).__name__)
print("note:", body.get("note"))
const res = await fetch("https://not.catastrophic.io/web-annotation");
const body = await res.json();
console.log("Content-Type:", res.headers.get("content-type"));
console.log("X-Chaos-Web-Annotation-Mode:", res.headers.get("x-chaos-web-annotation-mode"));
console.log("id present:", "id" in body);
console.log("motivation:", body.motivation);
console.log("body type:", typeof body.body);
console.log("target type:", typeof body.target);
console.log("note:", body.note);
package main
import (
"encoding/json"
"fmt"
"io"
"net/http"
)
func main() {
resp, _ := http.Get("https://not.catastrophic.io/web-annotation")
defer resp.Body.Close()
raw, _ := io.ReadAll(resp.Body)
var body map[string]any
json.Unmarshal(raw, &body)
fmt.Println("Content-Type:", resp.Header.Get("Content-Type"))
fmt.Println("X-Chaos-Web-Annotation-Mode:", resp.Header.Get("X-Chaos-Web-Annotation-Mode"))
_, hasId := body["id"]
fmt.Println("id present:", hasId)
fmt.Printf("motivation: %v\n", body["motivation"])
fmt.Printf("body type: %T\n", body["body"])
fmt.Printf("target type: %T\n", body["target"])
}
// Cargo.toml: reqwest = { version = "0.12", features = ["blocking", "json"] }
fn main() -> Result<(), Box> {
let resp = reqwest::blocking::get("https://not.catastrophic.io/web-annotation")?;
println!("Content-Type: {:?}", resp.headers().get("content-type"));
println!("X-Chaos-Web-Annotation-Mode: {:?}", resp.headers().get("x-chaos-web-annotation-mode"));
let body: serde_json::Value = resp.json()?;
println!("id present: {}", body.get("id").is_some());
println!("motivation: {:?}", body.get("motivation"));
println!("body: {:?}", body.get("body"));
println!("target: {:?}", body.get("target"));
Ok(())
}
import java.net.URI;
import java.net.http.*;
public class WebAnnotationChaos {
public static void main(String[] args) throws Exception {
var client = HttpClient.newHttpClient();
var req = HttpRequest.newBuilder(URI.create("https://not.catastrophic.io/web-annotation")).build();
var resp = client.send(req, HttpResponse.BodyHandlers.ofString());
System.out.println("Content-Type: " +
resp.headers().firstValue("Content-Type").orElse(""));
System.out.println("X-Chaos-Web-Annotation-Mode: " +
resp.headers().firstValue("X-Chaos-Web-Annotation-Mode").orElse(""));
System.out.println("Body: " + resp.body());
}
}
using var client = new HttpClient();
var resp = await client.GetAsync("https://not.catastrophic.io/web-annotation");
Console.WriteLine($"Content-Type: {resp.Content.Headers.ContentType}");
Console.WriteLine($"X-Chaos-Web-Annotation-Mode: " +
$"{resp.Headers.GetValues("X-Chaos-Web-Annotation-Mode").FirstOrDefault()}");
var body = await resp.Content.ReadAsStringAsync();
Console.WriteLine($"Body: {body}");
require "net/http"
require "json"
uri = URI("https://not.catastrophic.io/web-annotation")
Net::HTTP.start(uri.host, uri.port, use_ssl: true) do |http|
res = http.get(uri.request_uri)
puts "Content-Type: #{res['Content-Type']}"
puts "X-Chaos-Web-Annotation-Mode: #{res['X-Chaos-Web-Annotation-Mode']}"
body = JSON.parse(res.body)
puts "id present: #{body.key?('id')}"
puts "motivation: #{body['motivation']}"
puts "body class: #{body['body'].class}"
puts "target class: #{body['target'].class}"
end
$r = Invoke-RestMethod -Uri 'https://not.catastrophic.io/web-annotation' -ResponseHeadersVariable h
"Content-Type: $($h['Content-Type'])"
"X-Chaos-Web-Annotation-Mode: $($h['X-Chaos-Web-Annotation-Mode'])"
"id present: $($r.PSObject.Properties['id'] -ne $null)"
"motivation: $($r.motivation)"
"body type: $($r.body.GetType().Name)"
"target type: $($r.target.GetType().Name)"
headers
body