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 ?..
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 ?..
You’re right, this should be documented better. The right place to read about http_request_update
is here.
This section in the page you linked is partially correct:
To handle incoming HTTP requests, canisters must define methods for
http_requests
andhttp_requests_update
forGET
andPOST
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’shttp_request_update
method with HTTP clients such as curl. Instead, you can make aPOST
call to a canister’s HTTP endpoint, then configure the canister’shttp_request
method to upgrade the call tohttp_request_update
if necessary.
This part is correct and explains how to make the gateway call _update
.
The exact types you need to implement are defined here.
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
Sharing here in case it saves anyone hours of debugging in 2025, here is working example repo (canister as REST API with verifications):