Rust
Rust
POST application/json HTTPS Request
See more HTTP Examples
Demonstrates how to send an HTTPS POST where the request body and response body both have the application/json Content-Type. Also demonstrates how to add a few custom headers to the request.Chilkat Rust Downloads
// This requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code
let http = chilkat::Http::new();
// Add a few custom headers.
http.set_request_header("Client-ID", "my_client_id");
http.set_request_header("Client-Token", "my_client_token");
http.set_accept("application/json");
let url = "https://api.fiscallog.eu/sign/v1".to_string();
let json_request_body = "{ .... }".to_string();
let resp = chilkat::HttpResponse::new();
if http.http_str("POST", &url, &json_request_body, "utf-8", "application/json", &resp).is_err() {
println!("{}", http.last_error_text());
return;
}
println!("Response status code = {}", resp.status_code());
let json_response_str = resp.body_str();
println!("{}", json_response_str);