Rust
Rust
Shopify Receive Count of All Products in a Collection
See more Shopify Examples
Get a count of all products of a given collectionChilkat Rust Downloads
let rest = chilkat::Rest::new();
let _ = rest.set_auth_basic("SHOPIFY_PRIVATE_API_KEY", "SHOPIFY_PRIVATE_API_KEY");
if rest.connect("chilkat.myshopify.com", 443, true, true).is_err() {
println!("{}", rest.last_error_text());
return;
}
let sb_json = chilkat::StringBuilder::new();
if rest.full_request_no_body_sb("GET", "/admin/products/count.json?collection_id=841564295 ", &sb_json).is_err() {
println!("{}", rest.last_error_text());
return;
}
if rest.response_status_code() != 200 {
println!("Received error response code: {}", rest.response_status_code());
println!("Response body:");
println!("{}", sb_json.get_as_string().unwrap_or_default());
return;
}
let json = chilkat::JsonObject::new();
let _ = json.load_sb(&sb_json);
// The following code parses the JSON response.
// A sample JSON response is shown below the sample code.
let count = json.int_of("count");
// A sample JSON response body that is parsed by the above code:
// {
// "count": 1
// }
println!("Example Completed.");