I can add participant through command line command such as below successfully.
composer participant add -c admin@health-network -d '{"$class": "org.acme.health.Patient", "patientId": "10", "firstName": "Mae", "lastName": "smith", "email": "smith@gmail.com"}'
However, when I try javascript API, I get this error.
Error: Error trying to query business network. Error: chaincode error (status: 500, message: Error: Object with ID 'Participant:org.acme.health' in collection with ID '$sysregistries' does not exist) at channel.queryByChaincode.then.catch (/home/sara/health-network/angular-app/node_modules/composer-connector-hlfv1/lib/hlfconnection.js:809:34) at
Here is my javascript code
const BusinessNetworkConnection = require('composer-client').BusinessNetworkConnection;
let businessNetworkConnection = new BusinessNetworkConnection();
return businessNetworkConnection.connect('admin@health-network')
.then(() => {
return businessNetworkConnection.getParticipantRegistry('org.acme.health');
})
.then((participantRegistry) => {
let factory = businessNetworkConnection.getFactory();
let participant = factory.newResource('org.acme.health', 'Patient', '10');
participant.firstName = 'Mae';
participant.lastName = 'Smith';
participant.email ='smith@gmail.com'
return participantRegistry.add(participant);
})
.then(() => {
return businessNetworkConnection.disconnect();
})
.catch((error) => {
console.error(error);
process.exit(1);
});
I have a participant named 'Patient' in my .cto file.