public string GetDivisionId(string name) { string id = ""; try { var pageNumber = 1; var pageSize = 25; var divisionEntityListing = authorizationApi.GetAuthorizationDivisions(pageSize, pageNumber, null, null, null, null, null, null, name); //var divisionEntityListing = authorizationApi.GetAuthorizationDivisions(pageSize, pageNumber); foreach (var div in divisionEntityListing.Entities) { if (div.Name.Equals(name)) { AddLog("GetDivisionId: " + div.Id); id = div.Id; } } } catch (Exception ex) { AddLog($"Error in GetDivisionId: {ex.Message}"); MessageBox.Show(ex.Message, "Error", MessageBoxButtons.OK, MessageBoxIcon.Error); } return(id); }