# Call "canister\_status" from Rust agent

**URL:** <https://forum.dfinity.org/t/call-canister-status-from-rust-agent/12329>\
**Category:** Rust\
**Created:** [April 21, 2022, 12:12pm UTC](https://forum.dfinity.org/t/call-canister-status-from-rust-agent/12329 "2022-04-21T12:12:35Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![dymayday](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dymayday/32/4935_2.png) [@dymayday](https://forum.dfinity.org/u/dymayday)\
**Post date:** [April 21, 2022, 12:12pm UTC](https://forum.dfinity.org/t/call-canister-status-from-rust-agent/12329/1 "2022-04-21T12:12:35Z")

</div>

Hi, I would like to gather info from my canisters using the Rust agent by calling [canister\_status](https://smartcontracts.org/docs/interface-spec/index.html#ic-canister_status) using the management canister but here is what I get as a response :

`The replica returned an HTTP Error: Http Error: status 404 Not Found, content type “text/html”, content:

404 Not Found
# 404 Not Found

* * *
nginx/1.21.3 `

Using the interface spec [from here](https://smartcontracts.org/docs/interface-spec/index.html#ic-candid) :

> canister\_status : (record {canister\_id : principal}) → (record {  
> status : variant { running; stopping; stopped };  
> settings: definite\_canister\_settings;  
> module\_hash: opt blob;  
> memory\_size: nat;  
> cycles: nat;  
> });

```Rust
let management_canister_id = Principal::from_text("aaaaa-aa")?;
// Address is actually a different valid one on the ic.
let arg = Encode!( &Canister { canister_id: Principal::from_text("rrkah-fqaaa-aaaaa-aaaaq-cai") } )?;

agent
    .update(&management_canister_id, "canister_status")
     .with_arg(&arg)
     .call_and_wait(self.waiter.clone())
     .await?;

```

I’ve seen an example using JS, but does anyone managed to make it work with the Rust agent ?

(Sorry for the formatting, I have no idea to make it pretty looking for code snippet)

---

<div class="post-metadata">

**Author:** ![dymayday](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dymayday/32/4935_2.png) [@dymayday](https://forum.dfinity.org/u/dymayday)\
**Post date:** [April 21, 2022, 1:10pm UTC](https://forum.dfinity.org/t/call-canister-status-from-rust-agent/12329/2 "2022-04-21T13:10:10Z")

</div>

OK, I managed to get one step further by using the method [with\_effective\_canister\_id](https://agent-rust.netlify.app/ic_agent/agent/struct.updatebuilder#method.with_effective_canister_id) while building my update call using the agent and now I get this in return :

> The replica returned an HTTP Error: Http Error: status 403 Forbidden, content type “application/cbor”, content: Only controllers of canister \*\*\*\*\*-taaaa-aaaae-aag7a-cai can call ic00 method canister\_status

I am the controller of this one. I wonder what I’m missing here 🤔

---

<div class="post-metadata">

**Author:** ![dymayday](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dymayday/32/4935_2.png) [@dymayday](https://forum.dfinity.org/u/dymayday)\
**Post date:** [April 21, 2022, 1:56pm UTC](https://forum.dfinity.org/t/call-canister-status-from-rust-agent/12329/3 "2022-04-21T13:56:08Z")

</div>

hummm I’ve tried with [canister\_status from ic\_utils](https://docs.rs/ic-utils/latest/ic_utils/canister/struct.Canister.html#method.canister_status) but I get the same error message about not being a controller.

---

<div class="post-metadata">

**Author:** ![dymayday](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/dymayday/32/4935_2.png) [@dymayday](https://forum.dfinity.org/u/dymayday)\
**Post date:** [April 21, 2022, 1:57pm UTC](https://forum.dfinity.org/t/call-canister-status-from-rust-agent/12329/4 "2022-04-21T13:57:47Z")

</div>

So, I got it working !!

In order to work, the canister needs to have the principal-id as a controller and not only the wallet-id as needed with dfx 0.8.4.

I hope it will help someone else 😅
