When I use the underlying API to initiate a read_state request, an error is returned
code: 400
message: Could not parse body as read request: invalid type: sequence, expected a borrowed byte array
I compared the request structure with the read_state structure initiated by ic-py and found no difference
The method and structure of my request are [python language]
req_data ={
"content":{
"request_type":"read_state",
"sender":[154,44,112,11,77,82,44,203,66,97,101,176,73,44,234,233,120,191,202,45,62,47,241,73,21,255,114,15,2],
"paths":[
[
[114,101,113,117,101,115,116,95,115,116,97,116,117,115],
[130,17,109,11,15,130,51,105,82,211,31,73,32,195,70,151,53,12,11,140,12,80,123,81,57,241,210,133,131,190,187,107]
]
],
"ingress_expiry":1686567095535234200
},
"sender_pubkey":[1,1,1,1,6,1,42,134,72,1,61,2,1,6,5,43,129,4,0,10,3,66,0,4,134,211,31,2,69,27,64,158,105,120,206,70,197,174,195,47,221,206,190,172,71,142,187,253,122,147,189,102,168,128,62,44,223,40,61,197,227,70,76,245,88,13,54,198,128,164,97,177,54,29,154,192,239,153,129,252,255,201,103,123,49,219,33,127],
"sender_sig":[39,1,7,39,1,147,151,1,20,27,219,213,66,120,6,18,46,32,239,198,5,155,73,65,168,208,71,222,233,178,90,107,100,219,54,224,132,48,242,49,136,167,71,104,252,210,91,8,162,132,96,96,77,62,78,84,28,197,133,48,246,23,88,35]
}
url = "http://127.0.0.1:4943/api/v2/canister/xxxxx-xxxxx-xxxxx-xxxxx-cai/read_state"
headers = {'Content-Type': 'application/cbor'}
print("req_data: ", req_data)
cbor_data = cbor2.dumps(req_data)
print("cbor_data: ", cbor_data)
response = requests.post(url, data=cbor_data, headers=headers)
print("response status:", response.status_code)
print("response.content", response.content)
Supplementary Note
The paths structure is
"paths":[
[
b"request_status".to_vec(),
requests_id
]
]
why does it appear
Could not parse body as read request: invalid type: sequence, expected a borrowed byte array
error what did i do wrong