public async Task <ActionResult> Get(string orcid) { EmployeeDetails employeeDetails = _employeeService.GetByOrcid(orcid); if (employeeDetails != null && employeeDetails.Details == null) { HttpResponseMessage httpResponseMessage = await _employeeService.GetEmployeeDetailsFromAPI(employeeDetails.AccessToken); if (httpResponseMessage.StatusCode == System.Net.HttpStatusCode.OK) { XmlDocument doc = new XmlDocument(); doc.LoadXml(httpResponseMessage.Content.ReadAsStringAsync().Result); string json = JsonConvert.SerializeXmlNode(doc); Root Root = JsonConvert.DeserializeObject <Root>(json); employeeDetails.Details = Root; _employeeService.UpdateEmployeeDetails(employeeDetails); return(Ok(Root)); } } else if (employeeDetails != null && employeeDetails.Details != null) { return(Ok(employeeDetails.Details)); } return(BadRequest("Invalid ORCID")); }