# Cannot find a good example how to handle HTTP POST in Rust(update)

**URL:** <https://forum.dfinity.org/t/cannot-find-a-good-example-how-to-handle-http-post-in-rust-update/38567>\
**Category:** Developers\
**Tags:** rust\
**Created:** [December 7, 2024, 9:29am UTC](https://forum.dfinity.org/t/cannot-find-a-good-example-how-to-handle-http-post-in-rust-update/38567 "2024-12-07T09:29:24Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![let4be](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@let4be](https://forum.dfinity.org/u/let4be)\
**Post date:** [December 7, 2024, 9:29am UTC](https://forum.dfinity.org/t/cannot-find-a-good-example-how-to-handle-http-post-in-rust-update/38567/1 "2024-12-07T09:29:24Z")

</div>

I need to implement `http_request_update`  
but there’s NO documentation available

What’s going on with [HTTPS gateways and incoming requests | Internet Computer](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/advanced-features/handling-get-post-requests) ?..

---

<div class="post-metadata">

**Author:** ![Vivienne](https://sea1.discourse-cdn.com/flex023/user_avatar/forum.dfinity.org/vivienne/32/29170_2.png) [@Vivienne](https://forum.dfinity.org/u/Vivienne)\
**Post date:** [December 9, 2024, 12:28pm UTC](https://forum.dfinity.org/t/cannot-find-a-good-example-how-to-handle-http-post-in-rust-update/38567/3 "2024-12-09T12:28:26Z")

</div>

You’re right, this should be documented better. The right place to read about `http_request_update` is [here](https://internetcomputer.org/docs/current/references/http-gateway-protocol-spec#upgrade-to-update-calls).

[This section](https://internetcomputer.org/docs/current/developer-docs/smart-contracts/advanced-features/handling-get-post-requests#incoming-http-requests) in the page you linked is partially correct:

> To handle incoming HTTP requests, canisters must define methods for `http_requests` and `http_requests_update` for `GET` and `POST` requests respectively.

This is just wrong. In both cases the request first goes to `http_request` and only if you return `upgrade: true` will it be upgraded and re-called as `http_request_update`. The HTTP method does not matter.

> All HTTP requests are handled by the ICP HTTP Gateway, therefore you cannot make direct `POST` calls to a canister’s `http_request_update` method with HTTP clients such as curl. Instead, you can make a `POST` call to a canister’s HTTP endpoint, then configure the canister’s `http_request` method to [upgrade the call to `http_request_update` if necessary](https://internetcomputer.org/docs/current/references/http-gateway-protocol-spec#upgrade-to-update-calls).

This part is correct and explains how to make the gateway call `_update`.

The exact types you need to implement are defined [here](https://internetcomputer.org/docs/current/references/http-gateway-protocol-spec#canister-http-interface).

---

<div class="post-metadata">

**Author:** ![let4be](https://avatars.discourse-cdn.com/v4/letter/l/ecc23a/32.png) [@let4be](https://forum.dfinity.org/u/let4be)\
**Post date:** [December 9, 2024, 12:55pm UTC](https://forum.dfinity.org/t/cannot-find-a-good-example-how-to-handle-http-post-in-rust-update/38567/4 "2024-12-09T12:55:43Z")

</div>

Yea, already figured this out.

It’s just it took me like 3 hours., a task that should be doable in 15 min max with good documentation…

Those rust structs aren’t even exported anywhere from `ic_cdk` official rust crate, so I had to hack on a knee while debugging candid errors and trying to find this in the spec and see what am I even doing wrong

Poor devs who gonna use this for ICP

GET calls were easy because there are good examples, but POST… ugh

---

<div class="post-metadata">

**Author:** ![officex](https://avatars.discourse-cdn.com/v4/letter/o/bcef8e/32.png) [@officex](https://forum.dfinity.org/u/officex)\
**Post date:** [January 31, 2025, 9:57am UTC](https://forum.dfinity.org/t/cannot-find-a-good-example-how-to-handle-http-post-in-rust-update/38567/5 "2025-01-31T09:57:40Z")

</div>

Sharing here in case it saves anyone hours of debugging in 2025, here is working example repo (canister as REST API with verifications):

> **[response-verification/examples/http-certification/json-api at main ·...](https://github.com/dfinity/response-verification/tree/main/examples/http-certification/json-api)**
>
> Client side response verification for the Internet Computer - dfinity/response-verification
