Sample code for 30+ languages & platforms
Rust Requires Chilkat v11.0.0+

NetSuite OAuth1

See more OAuth1 Examples

Demonstrates adding OAUth1 authentication to a NetSuite REST API request.

Chilkat Rust Downloads

Rust

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

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

http.set_o_auth1(true);
http.set_o_auth_consumer_key("CONSUMER_KEY");
http.set_o_auth_consumer_secret("CONSUMER_SECRET");
http.set_o_auth_token("ACCESS_TOKEN");
http.set_o_auth_token_secret("TOKEN_SECRET");
http.set_o_auth_realm("ACCOUNT_ID");
http.set_o_auth_sig_method("HMAC-SHA256");

// Not sure if this is needed for NetSuite requests.
http.set_request_header("Cookie", "NS_ROUTING_VERSION=LAGGING");

// Replace ACCOUNT_ID with your actual account id, which is likely a 7-digit decimal number.
let resp = chilkat::HttpResponse::new();
if http.http_no_body("GET", "https://ACCOUNT_ID.suitetalk.api.netsuite.com/services/rest/record/v1/salesOrder", &resp).is_err() {
    println!("{}", http.last_error_text());
    return;
}

println!("Response Status Code: {}", resp.status_code());
println!("Response Body:");
println!("{}", resp.body_str());