Extract request common code to a new function: makeXMLRequest