TxHash to BlockHash using API
Although I don't fully understand your question, I can tell you that you can get the hash of a block at height Happy using the getblockhash api call:

getblockhash 277586 

Will result in the block hash for the block on the main chain at height 277586.

Block Explorer.com provides an online api for this api call: http://blockexplorer.com/q/getblockhash