User the Multichain Node.js API, how can I publish to a stream?

+1 vote

I am an experienced C#/Angular developer learning node.js and teh multichain API.  I am trying to simply POST a 'key' and 'data' to one of my streams.

This is the library I am using:

My code is returning errors.  This is the error it returns:

    : JSON.stringify(value);                                                                                           
TypeError: Converting circular structure to JSON                                                                       
    at Object.stringify (native)                                                                                       
    at stringify (C:\Dev\learning\nodeJS_Learning\PoE-API\poe\poe.API\node_modules\express\lib\response.js:1075:12)    
    at ServerResponse.json (C:\Dev\learning\nodeJS_Learning\PoE-API\poe\poe.API\node_modules\express\lib\response.js:24
    at ServerResponse.send (C:\Dev\learning\nodeJS_Learning\PoE-API\poe\poe.API\node_modules\express\lib\response.js:15
    at multichain.publish (C:\Dev\learning\nodeJS_Learning\PoE-API\poe\poe.API\routes\publish.js:31:44)                
    at (C:\Dev\learning\nodeJS_Learning\PoE-API\poe\poe.API\node_modules\multichain-node\lib\rpccall.js:40:
    at IncomingMessage.res.on (C:\Dev\learning\nodeJS_Learning\PoE-API\poe\poe.API\node_modules\multichain-node\lib\cli
    at emitNone (events.js:91:20)                                                                                      
    at IncomingMessage.emit (events.js:185:7)                                                                          
    at endReadableNT (_stream_readable.js:974:12)                                                                      


This is my API Call using Node.JS

  var multichain = require("multichain-node")({
        port: "6448",
        host: "",
        user: "multichainrpc",
        pass: "xxxxxxxxxx"
    });'/publish/', function (req, res) {
        var keyToPublish = req.body.key;
        var dataToPublish =;
        var streamName = "poe";
        if ((keyToPublish == undefined) || (dataToPublish == undefined)) {
            return res.send(400, "Please insert a data and key in the POST body to publish.");
        } else {          
            var dataToadd = new Buffer(dataToPublish).toString("hex");
                stream: "poe",
                key: "testKey-01",
                data: dataToadd
                (err) => {
                  //  console.log(res);
                    return res.status(200).send(res);





Can anyone help me and point me in the right direction? 




asked Jul 8, 2017 by jward01

1 Answer

+1 vote
Best answer
We don't know the details of this library, but if you have some way to debug the JSON-RPC request and response and paste them here, we can be a little wiser.
answered Jul 9, 2017 by MultiChain
selected Sep 21, 2017 by jward01