Google API post request to IBM blockchain error

0 votes

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.

Sep 14, 2018 in Blockchain by slayer
• 29,350 points
379 views

1 answer to this question.

0 votes

You have specified query as parameter to method and function but if you are trying to query using custom function ( Then 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"
    },
answered Sep 14, 2018 by digger
• 26,740 points

Related Questions In Blockchain

+1 vote
1 answer

Error while deploying chaincode in IBM Blockchain. Please help.

Try stripping out the 'tree/master' portion of ...READ MORE

answered Apr 26, 2018 in Blockchain by Christine
• 15,790 points
646 views
0 votes
1 answer
0 votes
1 answer
+1 vote
3 answers

Removing double quotes from a string from JSON response in PHP

Just remove the json_encode call, and it should work: $resp ...READ MORE

answered Sep 12, 2018 in Blockchain by digger
• 26,740 points
43,949 views
0 votes
1 answer

How do I add multiple recipients for transactions via Blockchain API?

Convert the recipes into JSON objects. x = ...READ MORE

answered Jul 6, 2018 in Blockchain by Perry
• 17,100 points
680 views
0 votes
1 answer

Truffle tests not running after truffle init

This was a bug. They've fixed it. ...READ MORE

answered Sep 11, 2018 in Blockchain by Christine
• 15,790 points
1,691 views
0 votes
1 answer

IBM Container Service blockchain deployment error.

This error might be caused because of ...READ MORE

answered Jul 10, 2018 in Blockchain by digger
• 26,740 points
541 views
0 votes
1 answer

How to make POST request on C# to blockr.io

By default UploadValues doesn't format the data ...READ MORE

answered Aug 30, 2018 in Blockchain by digger
• 26,740 points
1,387 views
webinar REGISTER FOR FREE WEBINAR X
REGISTER NOW
webinar_success Thank you for registering Join Edureka Meetup community for 100+ Free Webinars each month JOIN MEETUP GROUP