Sign in New API Help About

Posting to the dpaste.com API with Rust

353 bytes of Rust
Created 3 years, 11 months ago by dpaste.com — public
Viewed 3,001 times
https://dpaste.com/GG9X5CQLK
COPY TO CLIPBOARD SOFT WRAP RAW TEXT DUPLICATE DIFF
use reqwest;

fn main() {
    post();
}

fn post() {
    let params = [("content", "// Rust!"), ("syntax", "rust")];
    let client = reqwest::blocking::Client::new();
    let res = client
        .post("https://dpaste.com/api/")
        .form(&params)
        .send()
        .unwrap();
    println!("{:?}", res.headers()["location"]);
}

Related items


Share: