Calling contract function via web3.eth.sendTransaction doesnt work

By | July 21, 2018

Im learning how Blockchains work and created a private Blockchain to test some things. I deployed the following contract:

contract Greeter         
{
    address creator;     
    string greeting;     

    function Greeter(string _greeting) public   
    {
        creator = msg.sender;
        greeting = _greeting;
    }

    function greet() constant returns (string)          
    {
        return greeting;
    }

    function getBlockNumber() constant returns (uint) 
    {                                                   
        return block.number;
    }

    function setGreeting(string _newgreeting) 
    {
        greeting = _newgreeting;
    }


    function kill()
    { 
        if (msg.sender == creator)  
            suicide(creator);       
    }

}

Now I tried different methods to call the setter function I got the instance with using contract address and abi and called

instance.setGreeting.sendTransaction(...)

This one worked and with instance.greet() I got the new greeting. But then I tried an example from this page https://github.com/ethereumbook/ethereumbook/blob/develop/transactions.asciidoc#invocation and called

web3.eth.sendTransaction({from: eth.coinbase, to: contract_address, data: "0x4136862e000000000000000000000000000000000000000000004d794e65774772656574"})

where the data is created of the first 4 bytes of the Keccak256 hash of the prototype function setGreeting(string) and the String "MyNewGreet" encoded to Hex and padded to 32 bytes. The transaction is mined but instance.greet() still return the old greeting