Create and Verify Apostille code not working - Beginner

I am trying to create an apostille and then trying to verify it using the codes provided on the nem-sdk. link to example

When I create it using the following code, the Transaction Hash is generated correctly.

  var endpoint = nem.model.objects.create("endpoint")(nem.model.nodes.defaultTestnet, nem.model.nodes.defaultPort);
  console.log("Testnet and port" + nem.model.nodes.defaultTestnet, nem.model.nodes.defaultPort);

  var content = 'My 22ROCK22'
  var fileContent = nem.crypto.js.enc.Utf8.parse(content);


  var apostille = nem.model.apostille.create(common, "Test.txt", fileContent, "Test Apostille", nem.model.apostille.hashing["SHA256"], false, true, nem.model.network.data.testnet.id);


  // Serialize transfer transaction and announce
  nem.model.transactions.send(common, apostille.transaction, endpoint).then(function(res){
  	// If code >= 2, it's an error
  	if (res.code >= 2) {
  		console.error(res.message);
  	} else {
  		console.log("\nTransaction: " + res.message);
  		console.log("\nCreate a file with the fileContent text and name it:\n" + apostille.data.file.name.replace(/\.[^/.]+$/, "") + " -- Apostille TX " + res.transactionHash.data + " -- Date DD/MM/YYYY" + "." + apostille.data.file.name.split('.').pop());
  		console.log("When transaction is confirmed the file should audit successfully in Nano");
  		console.log("\nYou can also take the following hash: " + res.transactionHash.data + " and put it into the audit.js example");

      
    }
  }, function(err) {
    console.log("err ? ");
  	console.error( err );
  });

However, when I paste the transaction Hash in the code provided below that does the verification it always says that it’s invalid.

  var endpoint = nem.model.objects.create("endpoint")(nem.model.nodes.defaultTestnet, nem.model.nodes.defaultPort);


// Simulate the file content
var content = 'My 22ROCK22'

var fileContent = nem.crypto.js.enc.Utf8.parse(content );

// Transaction hash of the Apostille
var txHash = "d7abd8ab3bc8bef532900859b6209817621bc118fb842ff87039ddf365b71c3f";

// Get the Apostille transaction from the chain
nem.com.requests.transaction.byHash(endpoint, txHash).then(function(res) {
  // Verify


console.log("testnet and port "+ nem.model.nodes.defaultTestnet, nem.model.nodes.defaultPort);


  if (nem.model.apostille.verify(fileContent, res.transaction)) {
    console.log("Apostille is valid");
  } else {

    console.log("Apostille is invalid" + res.transaction.type);
  }
}, function(err) {
  console.log("Apostille is invalid");
  console.log(err);
});

I also found out that if i create a apostille using Nano wallet and used the transaction code generate in my verification sourcecode (provided above) it says that it is valid. I think there must be something missing in my Createsource code. Can someone please help me out.

I know this is super late but you don’t seem to have a common object. The common object will include information like your private key. This object authenticates you pushing transactions from your account onto the network. I’m sure you’ve figured this out but this was my 2 cents anyway :wink: :wink: