Sample code for 30+ languages & platforms
Rust

Outlook Calendar Delete Event

See more Outlook Calendar Examples

Removes the specified event from the containing calendar.

If the event is a meeting, deleting the event on the organizer's calendar sends a cancellation message to the meeting attendees.

Chilkat Rust Downloads

Rust

// This example requires the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.

let http = chilkat::Http::new();

// Use your previously obtained access token here: Get Outlook Calendar OAuth2 Access Token (Azure AD v2.0 Endpoint).

let json_token = chilkat::JsonObject::new();
if json_token.load_file("qa_data/tokens/outlookCalendar.json").is_err() {
    println!("{}", json_token.last_error_text());
    return;
}

http.set_auth_token(&json_token.string_of("access_token").unwrap_or_default());

// Specify the ID of the event to be deleted.
let event_id = "AQMkADAwATM0MDAAMS1iNTcwLWI2NTEtMDACLTAwCgBGAAADsVyfxjDU406Ic4X7ill8xAcA5_vF7TKKdE6bGCRqXyl2PQAAAgENAAAA5_vF7TKKdE6bGCRqXyl2PQAEaDkEcAAAAA==".to_string();

let sb_url = chilkat::StringBuilder::new();
let _ = sb_url.append("https://graph.microsoft.com/v1.0/me/events/");
let _ = sb_url.append(&event_id);

let url = sb_url.get_as_string().unwrap_or_default();
let resp = chilkat::HttpResponse::new();
if http.http_no_body("DELETE", &url, &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

println!("Response status code = {}", resp.status_code());

// The send succeeded if the response status code = 204.
if resp.status_code() != 204 {
    // If the event for the given ID does not exist, you'll get a 404 response code with this response body:

    // 		{
    // 		  "error": {
    // 		    "code": "ErrorItemNotFound",
    // 		    "message": "The specified object was not found in the store.",
    // 		    "innerError": {
    // 		      "date": "2021-04-19T00:02:04",
    // 		      "request-id": "0eac929a-6ee9-42f8-bb56-39799331c6f4",
    // 		      "client-request-id": "0eac929a-6ee9-42f8-bb56-39799331c6f4"
    // 		    }
    // 		  }
    // 		}

    println!("{}", resp.body_str());
    println!("Failed");
} else {
    println!("Event deleted.");
}