abstract common curl call into function