HTTPS API calls are not working (corrected)

I am having difficulty calling both update and query functions via HTTPS requests to my canister. I am sure it is some kind of json format error, but without logs it is proving to be very difficult to debug. As a result, could someone please provide me a sample request whose pattern I can follow?

Here is a request I am trying to make to call an update function pass_on, which has no arguments:

import requests
import json
import base64

link = "<my-canister-id>/call"

a = {"request_type": "call", "sender": "<my-principal-id>", "ingress_expiry": 1000, "canister_id": "<my-canister-id>", "method_name": "pass_on", "arg": "()"}

response =, json=a)


And I get the error:

Bad Request

What am I doing wrong here? Also, I have a function insert_me, which has arguments – considering that DFINITY syntax does not allow single quotes e.g “args” = “(‘a’, ‘b’, ‘c’)” and considering that json does not allow single quotes, how can I pass arguments into the function?

Thanks in advance!

Just making sure.

You did replace the canister-Id and principal-Id placeholders right ?

Yes faraz - I inserted my actual canister and principal IDs there. Thanks for checking that.

It looks like you are trying to send a json encoded object from python. That will not work, the interaction with the canisters is a bit more involved than that. You will most likely need to use an agent to interact with the IC from your apps. I believe there’s a WIP agent for python, but I haven’t checked on their progress recently. Try searching the forum using “python agent” and see if anything pops up.

If you want to get deeper into the IC and want to learn more, you should give the Interface Specification a thorough read. It details how the IC works, and the HTTP Interface will be of particular interest to your needs.


Yes not sure if anything other than cbor is supported by the IC

GitHub - dfinity/icx-proxy: A rust-based command line tool to serve as a gateway for a Internet Computer replica. cli over agent RS

These are the js and rust agents available, There is also a rumored C agent. the core issue here is you need CBOR to talk to IC

Please see http specification and Dfinity repo for examples

1 Like

Thanks for your responses @GLdev and @faraz.shaikh – I will take a look into it and try to get it to work.

1 Like

Hi Guys, Thanks - I got the API to work. The following python agent worked well:

Thanks once again!