Calling canisters without an argument requires a candid-bytes with no values?

Hello, when I call a canister method that doesn’t take any arguments without any bytes for the ‘arg’ it gives this error:
Call Reject: reject_code: 5: CANISTER_ERROR: Canister bayhi-7yaaa-aaaai-qahca-cai trapped explicitly: Custom(Cannot parse header
Caused by:
binary parser error: io error).

When I call a canister-method that doesn’t take any arguments with the ‘arg’ as these bytes: [68, 73, 68, 76, 0, 0] which is a candid-serialization of zero values, then it works.
Is this a documented feature/requirement or is this a bug? or is this something specific with the rust cdk function annotations?

If your canister speaks Candid (as it it should unless you have very good reasons do do otherwise), then the argument needs to be encoded in Candid – even if it is just the empty argument sequence ().

Think of a REST API expecting JSON, even if you send no values, it might require you to send "{}" or maybe "[]".

2 Likes