Deploy and expose chaincode as REST api on amazon managed blockchain hyperledger fabric 1.2

Which works perfectly. Complete exercise was done following this link.

I want to deploy and expose the chaincode as REST api. There is a sample project Amazon Managed Blockchain Workshop. They have used RESTful API, running as a Node.js Express application, using the Hyperledger Fabric Client SDK to query and invoke chaincode. I want to run non-profit chaincode example on Hyperledger Fabric Client prepared for AWS managed Blockchain Hyper Ledger 1.2

I have performed below steps:

Here are the steps how am I am running and testing the REST API.

cd ~/non-profit-blockchain/ngo-rest-api
nvm use lts/carbon
node app.js &

If I execute Register/enroll a user request

curl -s -X POST http://localhost:3000/users -H "content-type: application/x-www-form-urlencoded" -d 'username=john&orgName=Org1'

Instead of showing: response:

{"success":true,"secret":"","message":"michael enrolled Successfully"}

It shows below error message.

{"success":false,"message":"failed Error: Missing mspid parameter"}

I have also tried by adding mspid in the request but the error message is still same. What am I missing?

Here are contents of ngo-connection-profile.yaml

channels:
  mychannel:
    orderers:
      - orderer.com
    peers:
      peer1:
        endorsingPeer: true
        chaincodeQuery: true
        ledgerQuery: true
        eventSource: true
<pre><code>
organizations:
  Org1:
    mspid:
    peers:
      - peer1
    certificateAuthorities:
      - ca-org1
orderers:
  orderer.com:
    url: grpcs://orderer.n-XDXDXDXDXDSXDSXDXSDXSDXDSXDSXDS.managedblockchain.us-east-1.amazonaws.com:30001
    grpcOptions:
      ssl-target-name-override: orderer.n-XDXDXDXDXDSXDSXDXSDXSDXDSXDSXDS.managedblockchain.us-east-1.amazonaws.com
    tlsCACerts:
      path: /opt/home/managedblockchain-tls-chain.pem
</pre></code>
peers:
  peer1:
    url: grpcs://nd-NDNDNDNDNDNDNDNDNDNDND.m-AAAAAAAAAAAAAAAAAAAAAAAAA.n-XDXDXDXDXDSXDSXDXSDXSDXDSXDSXDS....
    eventUrl: grpcs://nd-NDNDNDNDNDNDNDNDNDNDND.m-AAAAAAAAAAAAAAAAAAAAAAAAA.n-XDXDXDXDXDSXDSXDXSDXSDXDSXDSXDS.....
    grpcOptions:
      ssl-target-name-override: nd-NDNDNDNDNDNDNDNDNDNDND.m-AAAAAAAAAAAAAAAAAAAAAAAAA.n-XDXDXDXDXDSXDSXDXSDXSDXDSXDSXDS.xxx
    tlsCACerts:
      path: /opt/home/managedblockchain-tls-chain.pem

certificateAuthorities:
ca-org1:
url: https://ca.m-AAAAAAAAAAAAAAAAAAAAAAAAA.n-XDXDXDXDXDSXDSXDXSDXSDXDSXDSXDS
httpOptions:
verify: false
tlsCACerts:
path: /opt/home/managedblockchain-tls-chain.pem
registrar:
- enrollId: aaaaaaaa
enrollSecret: XXXXXXXXXXX
caName: m-AAAAAAAAAAAAAAAAAAAAAAAAA


#blockchain #node-js #go #hyperledger

11 Likes14.80 GEEK