struggle with crafting an API request

+75 votes

hi everyone,

I am having difficulties with crafting my first API-request over postman.

I have set up a chain, I have the explorer and the web-demo running successfully - pretty much default values everywhere:


default-network-port = 5759
default-rpc-port = 5758
chain-name = chain1

when running a command from the console, everthing works:

bbking@bc-debian:~/.multichain/chain1$ multichain-cli chain1 getinfo

    "version" : "2.3.3",
    "nodeversion" : 20303901,
    "edition" : "Community",
    "protocolversion" : 20013,
    "chainname" : "chain1",
    "description" : "MultiChain chain1",
    "protocol" : "multichain",
    "port" : 5759,

now my first question is, do I connect from an external host over port 5759 or 5758?

I wanted to replicate the "getinfo" command from postman:[]&id=13054619-1712335590&chain_name=chain1

I have populated the "params" tab with the parameters as you can see.

I also activated "Basic Authorization" with the credentials from multichain.conf

On the "headers" tab, I've set these key-value pairs:
"Content-type" : "application/json"
"Accept" : "application/json"
"Content-length" : the length of the parameter string starting from "?" in the example above.

Now, when I send the request to port 5759, I get a "Could not get response"

when I send the request to port 5758 with "Content-length" activated, it times out.
without "Content-length" activated, I instantly get a "404 Not found"

Can someone help me with what am I doing wrong?

Thanks a lot in advance!

asked Apr 5 by bbking

1 Answer

0 votes

For the node JSON-RPC API, you use the RPC port, i.e. 5758.

It looks like you might be trying to pass the method name and other params as parameters in the URL of a GET request. But they need to be in JSON format in the body of a POST request.

Whenever you use multichain-cli, it shows you what the POST request body contains – like in the example you showed above:

answered Apr 6 by MultiChain
thanks, now I got it working with postman with setting the body parameter as "Raw" and the value is {"method":"getinfo","params":[],"id":"37999825-1712336614","chain_name":"chain1"} as a JSON object.

Tried the same with Node-Red and I was struggling to get the body parameter right.
I tried the JSON object from above as an object but also converted into a string, but I also get 403 forbidden error.
Then I realised the docker container for Node-Red had a different ip range ( than my host computer ( so had to include that range in my multichain.conf and voila! it worked!
Now I create the msg.payload as a JSON object, convert it with the JSON-parser node to JSON-string and send to with the http request to multichain.
Great, thanks for the update!