Given this code:
let client = ManagementCanister::create(agent);
client
.delete_canister_snapshot(&canister, &snapshot_id.id)
.await?;
When I run this code for any canister on the local dfx network, it does work, but when running for a canister on IC mainnet, an error is returned:
The replica returned an HTTP Error: Http Error: status 400 Bad Request, content type "text/plain; charset=utf-8", content: error: canister_not_found
details: The specified canister does not exist.
This code however works for both local and mainnet canisters:
let call: AsyncCaller<'_, ()> = client.update(MgmtMethod::DeleteCanisterSnapshot.as_ref())
.with_arg(In {
canister_id: canister,
snapshot_id: &snapshot_id.id,
})
.with_effective_canister_id(canister)
.build();
call.await?;
The difference with the delete_canister_snapshot() implementation is this line:
.with_effective_canister_id(canister)