Zig
Zig
HTTP DELETE with Body
See more HTTP Examples
Demonstrates how to send a DELETE request with a body.Chilkat Zig Downloads
const std = @import("std");
const chilkat = @import("chilkat");
pub fn main(init: std.process.Init) !void {
const alloc = init.arena.allocator();
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
const http = try chilkat.Http.init();
defer http.deinit();
// Use the HttpStr method (or HttpSb) to send a DELETE request with a body.
const request_body = "{ \"abc\": 123 }";
const resp = try chilkat.HttpResponse.init();
defer resp.deinit();
http.httpStr("DELETE", "https://example.com/something", request_body, "utf-8", "application/json", resp) catch {
std.debug.print("{s}\n", .{try http.getLastErrorText(alloc)});
return;
};
std.debug.print("Response status: {d}\n", .{resp.getStatusCode()});
std.debug.print("Response body: \n", .{});
std.debug.print("{s}\n", .{try resp.getBodyStr(alloc)});
}