Rust agent.upate can not throw the error :reject_code: 3, reject_message: "Canister 4grvp-niaaa-aaaah-qboma-cai has no update method 'getTransactions'"

pub async fn get_transactions(canister_id: &String, agent: &Agent,from: &Nat, to:&Nat) -> DSWAP_DATA::TxRecords{
    println!("[Query DSWP:get_transactions]:Start! Canister_id {:#?}", canister_id);

    let canister_str = String::from(canister_id);
    let canister_id = Principal::from_text(canister_str).unwrap();
    let function_str = String::from("getTransactions");
    
    let waiter = garcon::Delay::builder()
        .throttle(std::time::Duration::from_millis(500))
        .timeout(std::time::Duration::from_secs(60 * 5))
        .build();

    let response = agent.update(&canister_id, function_str)
        .with_arg(&Encode!(from,to).unwrap())
        .call_and_wait(waiter)
        .await
        .unwrap();
    let result = Decode!(response.as_slice(), DSWAP_DATA::TxRecords);
    result.unwrap()
}

run above code i get the error reject_code: 3, reject_message: “Canister 4grvp-niaaa-aaaah-qboma-cai has no update method ‘getTransactions’”

but when i call

i get the right result
how can I fix this bug

when i use following command in ternimal

dfx canister  --no-wallet --network ic  call --query 4bqt3-aqaaa-aaaah-qbomq-cai getTransactions '(0:nat,100:nat)'

I got the right result

looks like your getTransactions function is a query function and your rust code is trying to call an update function