title: Hyperledger-composer: Expected Resource or Concept
body: <p>I'm getting <code>expected resource or concept</code> errors with two functions. I am creating the Concept and Resource and assigning their values the correct way, according to the hyperledger composer API example. </p>
  
  <p>What my code does:</p>
  
  <p><strong><code>createUser()</code></strong><br>
  <code>User</code> contains a Concept called <code>UserData</code> that consists of four String fields. I try to create a new user by first creating a new <code>UserData</code> Concept and updating its fields, then setting the User's userData to this new Concept.</p>
  
  <p><strong><code>grantAccess()</code></strong><br>
  Search for a user in the registry by ID and set its <code>access</code> value to true.</p>
  
  <p>Both functions throw <code>Error: Error trying invoke business network. Error: No valid responses from any peers. Response from attempted peer comms was an error: Error: chaincode error (status: 500, message: Error: Expected a Resource or Concept.)</code></p>
  
  <blockquote>
    <p>.cto:</p>
  </blockquote>
  
  <pre><code>namespace org.acme.biznet
  
  concept UserData {
      o String name
      o String id
      o String postcode
      o String birthdate
  }
  
  participant User identified by userId {
      o String userId
      o String name
      o UserData userData
      o Boolean access
  }
  
  transaction createUser {
    o UserData newUserData
  }
  
  transaction grantAccess {
      o String userId
  }
  
  event NewUserCreated {
      o User user
  }
  
  event UserAccessRightsChanged {
      o User user
      o Boolean oldValue
      o Boolean newValue
  }
  </code></pre>
  
  <blockquote>
    <p>.js:</p>
  </blockquote>
  
  <pre><code>/**
  * Creates a new user.
  * @param {org.acme.biznet.createUser} createUser The create user transaction.
  * @transaction
  */    
  function createUser(createUser) {
  
      // create new instance of a User
      var factory = getFactory();
      var newUser = factory.newResource('org.acme.biznet', 'User', '123');
      var newData = factory.newConcept('org.acme.biznet', 'UserData');
  
      newData.name = createUser.newUserData.name;
      newData.id = createUser.newUserData.id;
      newData.postcode = createUser.newUserData.postcode;
      newData.birthdate = createUser.newUserData.birthdate;
  
      newUser.userData = newData;
  
      return getParticipantRegistry('org.acme.biznet.User')
      .then(function (userRegistry) {
          return userRegistry.update(createUser.user);
      })
      .then(function () {
          // Emit an event for the new user creation.
          var event = getFactory().newEvent('org.acme.biznet', 'NewUserCreated');
          event.user = newUser;
          emit(event);
      });
  }
  
  /**
  * Grants access to the user data.
  * @param {org.acme.biznet.grantAccess} userGrantAccess The grantAccess transaction.
  * @transaction
  */
  function grantAccess(userGrantAccess) {
  
      var existingAccessValue;
      var theUser;
  
      // Get the user from the registry given the id
      getParticipantRegistry('org.acme.biznet')
          .then(function (participantRegistry) {
              // Get the specific User from the participant registry.
              return participantRegistry.get(userGrantAccess.userId);
          })
          .then(function (user) {
              theUser = user;
              existingAccessValue = user.access;
              user.access = true;
          });
  
      // Get and update the user registry
      return getParticipantRegistry('org.acme.biznet.User')
          .then(function (userRegistry) {
              return userRegistry.update(theUser);
          })
          .then(function () {
              // Emit an event for the modified user rights.
              var event = getFactory().newEvent('org.acme.biznet', 'UserAccessRightsChanged');
              event.user = theUser;
              event.oldValue = existingAccessValue;
              event.newValue = theUser.access;
              emit(event);
          });
  }
  </code></pre>