Calculate hash of block header

Calculate hash of block header

I'm trying to calculate the hash of block #502871. This is the block:
{
"result": {
    "hash": "00000000000000000020cf2bdc6563fb25c424af588d5fb7223461e72715e4a9",
    "confirmations": 35,
    "strippedsize": 976261,
    "size": 1064277,
    "weight": 3993060,
    "height": 502871,
    "version": 536870912,
    
Read more