Hyperledger composer calling external REST API

peterDalis. st

I am a developer with hyperledger composer. I try to use Calling an HTTP or REST API from Transaction Processor Functions with method POST and request body but I have error status code 500. I want to use method POST with request body to my server.

My code:

async function testStocks(transaction) {

    const participant = getCurrentParticipant();
    const json = '{"name:tester"}';//my request body

    await request.post({ uri: 'http://www...', json });

    // Update the current participant in the participant registry.
    const participantRegistry = await getParticipantRegistry('org.example.Trader');
    await participantRegistry.update(participant);

}

My error:

{
  "error": {
    "statusCode": 500,
    "name": "Error",
    "message": "Error trying invoke business network. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: StatusCodeError: 400 - undefined",
    "stack": "Error: Error trying invoke business network. Error: No valid responses from any peers.\nResponse from attempted peer comms was an error: Error: 2 UNKNOWN: error executing chaincode: transaction returned with failure: StatusCodeError: 400 - undefined\n    at _initializeChannel.then.then.then.then.catch (/home/pc/.nvm/versions/node/v8.10.0/lib/node_modules/composer-rest-server/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:965:34)\n    at <anonymous>"
  }
}
Saad Bin Shahid

participant variable is undefined in await participantRegistry.update(participant);.

You are missing code from the example @ https://hyperledger.github.io/composer/latest/integrating/call-out.

// Get the current participant, and update their stock and balance.
const participant = getCurrentParticipant();
// update participant here...  <<--------------------

// Update the current participant in the participant registry.
const participantRegistry = await getParticipantRegistry('org.example.Trader');
await participantRegistry.update(participant);

Collected from the Internet

Please contact [email protected] to delete if infringement.

edited at
0

Comments

0 comments
Login to comment

Related

Using passport-http on Hyperledger composer REST API

Hyperledger Composer REST API does not generate transaction interfaces

How to implement Hyperledger composer rest api by own with nodejs?

Hyperledger composer rest server not updating

Django Rest Framework: Calling Internal API from External API

Hyperledger Composer vs Hyperledger Nodejs Api

Error creating hyperledger composer rest server

Hyperledger Composer - Rest Server Local Passport Strategy

Hyperledger Composer Rest Server Query from WebApp

Hyperledger Composer REST server wallet not unique

Calling External API with Javascript

Hyperledger Composer Add Participant through Javascript API

Error: Cannot find module './api' (Hyperledger composer)

Find Client Public IP Address Inside Controller of rest web API with out calling external api

Calling a REST API in R

can rest server be launched inside the hyperledger/composer-playground container?

Hyperledger Composer REST - 500 transaction error + issue new identity for participant

Using Hyperledger Composer REST Server multiuser without passport

Version error when launching hyperledger composer rest server docker

SocketException when calling external api

Calling an External API That Fails Randomly

Cannot Post Hyperledger Transaction on Rest API

Calling external data on Hyperledger Fabric Chaincode (external data as input in business logic)

Django rest framework & external api

Calling puppeteer from rest api

Hyperledger composer: calling a query within a transaction that updated an asset returns old results

What are the best practices for calling an external api?

Calling external API and parsing JSON Object

Calling a external API class on Observer best practice

TOP Ranking

  1. 1

    Failed to listen on localhost:8000 (reason: Cannot assign requested address)

  2. 2

    How to import an asset in swift using Bundle.main.path() in a react-native native module

  3. 3

    Loopback Error: connect ECONNREFUSED 127.0.0.1:3306 (MAMP)

  4. 4

    pump.io port in URL

  5. 5

    Spring Boot JPA PostgreSQL Web App - Internal Authentication Error

  6. 6

    BigQuery - concatenate ignoring NULL

  7. 7

    ngClass error (Can't bind ngClass since it isn't a known property of div) in Angular 11.0.3

  8. 8

    Do Idle Snowflake Connections Use Cloud Services Credits?

  9. 9

    maven-jaxb2-plugin cannot generate classes due to two declarations cause a collision in ObjectFactory class

  10. 10

    Compiler error CS0246 (type or namespace not found) on using Ninject in ASP.NET vNext

  11. 11

    Can't pre-populate phone number and message body in SMS link on iPhones when SMS app is not running in the background

  12. 12

    Generate random UUIDv4 with Elm

  13. 13

    Jquery different data trapped from direct mousedown event and simulation via $(this).trigger('mousedown');

  14. 14

    Is it possible to Redo commits removed by GitHub Desktop's Undo on a Mac?

  15. 15

    flutter: dropdown item programmatically unselect problem

  16. 16

    Change dd-mm-yyyy date format of dataframe date column to yyyy-mm-dd

  17. 17

    EXCEL: Find sum of values in one column with criteria from other column

  18. 18

    Pandas - check if dataframe has negative value in any column

  19. 19

    How to use merge windows unallocated space into Ubuntu using GParted?

  20. 20

    Make a B+ Tree concurrent thread safe

  21. 21

    ggplotly no applicable method for 'plotly_build' applied to an object of class "NULL" if statements

HotTag

Archive