# Error when making HTTP call in Motoko: Canister http responses were different across replicas, and no consensus was reached

**URL:** <https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828>\
**Category:** Developers\
**Created:** [January 19, 2024, 7:28pm UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828 "2024-01-19T19:28:24Z")\
**Posts on this page:** 9\
**Page:** 1

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [January 19, 2024, 7:28pm UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828/1 "2024-01-19T19:28:24Z")

</div>

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:

```auto
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`

```auto
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`:

```auto
 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;
};

```

---

<div class="post-metadata">

**Author:** ![LightningLad91](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/lightninglad91/32/5373_2.png) [@LightningLad91](https://forum.dfinity.org/u/LightningLad91)\
**Post date:** [January 19, 2024, 8:34pm UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828/2 "2024-01-19T20:34:12Z")

</div>

I think you might need to add an Idempotency-Key header. I haven’t made it this far in practice but I know when I was reading the IC guide for outcalls it says to use idempotency keys

[https://internetcomputer.org/docs/current/developer-docs/integrations/https-outcalls/https-outcalls-post#important-notes-on-post-requests](https://internetcomputer.org/docs/current/developer-docs/integrations/https-outcalls/https-outcalls-post#important-notes-on-post-requests)

---

<div class="post-metadata">

**Author:** ![h1teshtr1path1](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/h1teshtr1path1/32/24662_2.png) [@h1teshtr1path1](https://forum.dfinity.org/u/h1teshtr1path1)\
**Post date:** [January 20, 2024, 2:00am UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828/3 "2024-01-20T02:00:13Z")

</div>

It’s mainly because of your http\_post request is getting different responses when multiple replicas hitting same url with same request.

You need to correctly handle the response inside transform function, to make it equal across all replicas, for them to reach the consensus.

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [January 20, 2024, 6:51am UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828/4 "2024-01-20T06:51:12Z")

</div>

> [@h1teshtr1path1](#):
>
> You need to correctly handle the response inside transform function, to make it equal across all replicas, for them to reach the consensus.

How do I go about troubleshooting the issue with my tansform function? I’m not sure what the issue with my transform function might be. Is there any way I could see the the responses that the replicas are sending back? That’d be useful for diagnosing the problem.

---

<div class="post-metadata">

**Author:** ![h1teshtr1path1](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/h1teshtr1path1/32/24662_2.png) [@h1teshtr1path1](https://forum.dfinity.org/u/h1teshtr1path1)\
**Post date:** [January 20, 2024, 7:23am UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828/5 "2024-01-20T07:23:12Z")

</div>

I would have used postman to check response of http post request.  
Try hitting url with same post request multiple times and check what actual difference those responses have in there, and then try to process the post request responses inside transform function accordingly to make them same to reach consensus .  
For a good example of processing http request responses inside transform function you can refer to [https://github.com/dfinity/exchange-rate-canister/tree/main](https://github.com/dfinity/exchange-rate-canister/tree/main)

Also if you want to try non replicated http outcalls to avoid transform function for fire n forget type of http requests you can also check :  
[https://forum.dfinity.org/t/non-replicated-https-outcalls/26627](https://forum.dfinity.org/t/non-replicated-https-outcalls/26627)

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [January 24, 2024, 7:25am UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828/6 "2024-01-24T07:25:38Z")

</div>

I ended up resolving this error by increasing the `ingress_expirey` value. I initially had it set to just 5 seconds. Increasing it to 60 seconds resolved the bug.

---

<div class="post-metadata">

**Author:** ![bruno353](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/bruno353/32/15709_2.png) [@bruno353](https://forum.dfinity.org/u/bruno353)\
**Post date:** [August 22, 2024, 7:44pm UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828/7 "2024-08-22T19:44:46Z")

</div>

In which part do you configure the ingress\_expirey?

---

<div class="post-metadata">

**Author:** ![Jesse](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/jesse/32/37836_2.png) [@Jesse](https://forum.dfinity.org/u/Jesse)\
**Post date:** [August 22, 2024, 11:35pm UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828/8 "2024-08-22T23:35:25Z")

</div>

@bruno353 It goes within the `content` of the envelope.

```auto
public type Envelope = {
        content: EnvelopeContent;
        sender_pubkey: [Nat8];
        sender_sig: [Nat8];
    };

```

```auto
public type EnvelopeContent = {
        ingress_expiry: Nat64;
        sender: Principal;
        canister_id: Principal;
        method_name: Text;
        arg: [Nat8];
    };

```

---

<div class="post-metadata">

**Author:** ![Unite](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/unite/32/19800_2.png) [@Unite](https://forum.dfinity.org/u/Unite)\
**Post date:** [August 31, 2024, 3:03pm UTC](https://forum.dfinity.org/t/error-when-making-http-call-in-motoko-canister-http-responses-were-different-across-replicas-and-no-consensus-was-reached/26828/9 "2024-08-31T15:03:58Z")

</div>

i am having this issue. but i can not find this on my app. where do I see this?
