0 votes
1 view
in Blockchain by (12.8k points)

I am trying to send reqest from google api script to IBM Blockchain SaaS project Bluemix. The code is:

var url = "https://24f7d912-60f4-4eaf-89c6-b3e34b2247f9_vp1-api.blockchain.ibm.com:443/chaincode";

  var headers =

  {"jsonrpc": "2.0",

   "method": "query",

   "params": {

       "type": 1,

       "chaincodeID": {

           "name": "c86de893fe7203e09add8c47237ffa377814311d9c3cb21ca4d3d5c4eeca65294d801a1f2e5a2d6b22b91096d9c8e42910046d2ab02d295ad0a0fb0b716e9a69"

       },

       "ctorMsg": {

           "function": "query",

           "args": ["b"]

        },

        "secureContext": "dashboarduser_type0_953add49d4"

    },

    "id": 1

  };

  var options =

     {

      "method" : "post",

      "headers" : headers,

       "MuteHttpExceptions":false

     };

  var response = UrlFetchApp.fetch(url,options);

  var responseString=response.getContentText();  

}

The error message is:

{"jsonrpc":"2.0","error":{"code":-32600,"message":"Invalid request","data":"Client must supply a payload for chaincode requests."},"id":null}

The request from Firefix Poster was answered correctly.

1 Answer

0 votes
by (29.8k points)

specify method as query and function as custom function name that you have created in chaincode as:

{"jsonrpc": "2.0",
"method": "query",
   "params": {
       "type": 1,
       "chaincodeID": {
           "name": "chainId"
       },
       "ctorMsg": {
           "function": "customfunctionName",
           "args": ["b"] //Argument to that custom function
        },
        "secureContext": "dashboarduser_type0_953add49d4"
    },

Related questions

0 votes
1 answer
0 votes
1 answer
asked Jul 23, 2019 in Blockchain by Abhishek_31 (12.8k points)
0 votes
1 answer
asked Jul 23, 2019 in Blockchain by Abhishek_31 (12.8k points)
Welcome to Intellipaat Community. Get your technical queries answered by top developers !


Categories

...