Rust (using reqwest crate)
Prerequisites
- ezePing API Key, available instantly after creating an account. You can copy it from here (opens in a new tab).
- Event Category Name is the category to which you want to send this event. If you haven't created an event category yet, you can create a new category here (opens in a new tab).
Payload
You can send any payload, as long as it is in a valid JSON format.
json
'fields': {
'amount': 50,
'plan': 'PRO',
'email': 'user@email.com'
}
Installation
Rust
use reqwest::Client;
use serde_json::json;
use tokio;
#[tokio::main]
async fn main() -> Result<(), Box<dyn std::error::Error>> {
let client = Client::new();
let url = "https://www.ezeping.com/api/v1/events";
let response = client.post(url)
.bearer_auth("<YOUR_API_KEY>")
.json(&json!({
"category": "<YOUR_CATEGORY_NAME>",
"fields": {
"field1": "value1", // For example, user ID
"field2": "value2" // For example, user email
}
}))
.send()
.await?;
if response.status().is_success() {
let response_text = response.text().await?;
println!("Request was successful: {}", response_text);
} else {
println!("Request failed with status: {}", response.status());
}
Ok(())
}