Rust
Rust
MYOB: Update a Category
See more MYOB Examples
Sends a PUT to update a category.Chilkat Rust Downloads
// This example assumes the Chilkat API to have been previously unlocked.
// See Global Unlock Sample for sample code.
let http = chilkat::Http::new();
// Implements the following CURL command:
// curl --request PUT "https://ar1.api.myob.com/accountright/c06778dd-4371-4a83-975f-522df65d7574/GeneralLedger/Category/{{category_id}}" \
// --header "Authorization: Bearer ACCESS_TOKEN" \
// --header "x-myobapi-key: This is your API Key" \
// --header "x-myobapi-version: v2" \
// --header "Accept-Encoding: gzip,deflate" \
// --data "{
// \"UID\": \"20b483b2-9a89-4793-b8c3-2da1a6284e1f\",
// \"DisplayID\": \"Postman001\",
// \"Name\": \"Postman sample\",
// \"Description\": \"This has been updated via Postman\",
// \"IsActive\": true,
// \"RowVersion\": \"-8858580467037765632\"
// }"
// Use this online tool to generate code from sample JSON:
// Generate Code to Create JSON
// The following JSON is sent in the request body.
// {
// "UID": "20b483b2-9a89-4793-b8c3-2da1a6284e1f",
// "DisplayID": "Postman001",
// "Name": "Postman sample",
// "Description": "This has been updated via Postman",
// "IsActive": true,
// "RowVersion": "-8858580467037765632"
// }
let json = chilkat::JsonObject::new();
let _ = json.update_string("UID", "20b483b2-9a89-4793-b8c3-2da1a6284e1f");
let _ = json.update_string("DisplayID", "Postman001");
let _ = json.update_string("Name", "Postman sample");
let _ = json.update_string("Description", "This has been updated via Postman");
let _ = json.update_bool("IsActive", true);
let _ = json.update_string("RowVersion", "-8858580467037765632");
http.set_request_header("Authorization", "Bearer ACCESS_TOKEN");
http.set_request_header("x-myobapi-key", "This is your API Key");
http.set_request_header("Accept-Encoding", "gzip,deflate");
http.set_request_header("x-myobapi-version", "v2");
let sb_request_body = chilkat::StringBuilder::new();
let _ = json.emit_sb(&sb_request_body);
let resp = chilkat::HttpResponse::new();
if http.http_sb("PUT", "https://ar1.api.myob.com/accountright/c06778dd-4371-4a83-975f-522df65d7574/GeneralLedger/Category/{{category_id}}", &sb_request_body, "utf-8", "application/json", &resp).is_err() {
println!("{}", http.last_error_text());
return;
}
let resp_status_code = resp.status_code();
println!("Response Status Code = {}", resp_status_code);
if resp_status_code != 200 {
println!("Response Header:");
println!("{}", resp.header());
println!("Response Body:");
println!("{}", resp.body_str());
println!("Failed.");
return;
}
println!("Success.");