Actually, I copied it from restclient.py - which should probably use the function from commons as well.