I’m attempting to make an authenticated HTTP Post call in Motoko. When I make the HTTP call, the error listed below is thrown. I’ve seen this error previously when attempting to make an HTTP Get call and was able to resolve the error by altering the tranform()
function that I designate within the HTTP request so that the headers
array is always empty, but that doesn’t seem to be a solution in this case as the error persists. I suspect that my transform function may be the culprit here, but I also wonder if this error could be the result of an improperly generated ECDSA signature when signing the envelope. Below, I’ve also listed the http_request
that I’m sending and the transform()
function that I’m using. Does anyone see any obvious issues with what I have? or can anyone confirm whether or not this error could come by way of an improperly generated message signature? thank you
Error message that I’m getting:
Call was rejected:
Request ID: 7a89a2ddb2d271c4199c93daf91b5e388da71af291adf3c7183dbee75767b3fb
Reject code: 4
Reject text: Canister http responses were different across replicas, and no consensus was reached
my HTTP request input
let http_request = {
body = //CBOR encoding of the envelope
url = //API endpoint where the method I'm calling is found
headers = [{name = "content-type"; value= "application/cbor"}]
//transformFn defined below
transform = ?{ function = transformFn; context = Blob.fromArray([]); };
method = #post;
max_response_bytes = ?Nat64.fromNat(1024 * 1024);
};
here is how I defined transformFn
:
public query func transformFn({context: Blob; response: IC.http_response}) : async IC.http_response {
let transformed : IC.http_response = {
status = response.status;
body = response.body;
headers = [];
};
transformed;
};