public DnBProfile GetDnBProfile(string dun) { DnBProfile dnbProfile = new DnBProfile(); dnbProfile.BusinessBasicInfo = new Candidate(); dnbProfile.PricipalOfficers = new List <PrincipalOfficer>(); try { //Build the API request to be send. _Request = WebRequest.Create(new Uri(String.Format("{0}{1}", _DnBBasicURL, StatementBuilder.CompanyProfile(dun)))); _Request.Method = "GET"; _Request.ContentType = "application/json; charset=UTF-8"; _Request.Headers.Add("Authorization", _Token); //Call the API and get a response. HttpWebResponse response = (HttpWebResponse)_Request.GetResponse(); if (response.StatusCode == HttpStatusCode.OK) { using (var streamReader = new StreamReader(response.GetResponseStream())) { var companyProfile = JsonConvert.DeserializeObject <DnB.NET.JsonModels.CompanyProfileInformation.CompanyProfileInfo>(streamReader.ReadToEnd()); if (companyProfile == null) { _ErrorMessage = "No results found"; return(null); } //Get basic info dnbProfile.BusinessBasicInfo.DUN = dun; dnbProfile.BusinessBasicInfo.BusinessName = companyProfile.OrderProductResponse.OrderProductResponseDetail.Product.Organization.OrganizationName.OrganizationPrimaryName[0].OrganizationName.Value; dnbProfile.BusinessBasicInfo.StreetAddress = companyProfile.OrderProductResponse.OrderProductResponseDetail.Product.Organization.Location.PrimaryAddress[0].StreetAddressLine[0].LineText; dnbProfile.BusinessBasicInfo.StreetAddress2 = ""; dnbProfile.BusinessBasicInfo.City = companyProfile.OrderProductResponse.OrderProductResponseDetail.Product.Organization.Location.PrimaryAddress[0].PrimaryTownName; dnbProfile.BusinessBasicInfo.State = companyProfile.OrderProductResponse.OrderProductResponseDetail.Product.Organization.Location.PrimaryAddress[0].TerritoryAbbreviatedName; dnbProfile.BusinessBasicInfo.PostalCode = companyProfile.OrderProductResponse.OrderProductResponseDetail.Product.Organization.Location.PrimaryAddress[0].PostalCode; dnbProfile.BusinessBasicInfo.PhoneNumber = companyProfile.OrderProductResponse.OrderProductResponseDetail.Product.Organization.Telecommunication.TelephoneNumber[0].TelecommunicationNumber; dnbProfile.BusinessBasicInfo.FaxNumber = ""; dnbProfile.CompanyLineBusiness = companyProfile.OrderProductResponse.OrderProductResponseDetail.Product.Organization.ActivitiesAndOperations.LineOfBusinessDetails[0].LineOfBusinessDescription.Value; dnbProfile.TotalEmployees = 0; dnbProfile.Yearstarted = companyProfile.OrderProductResponse.OrderProductResponseDetail.Product.Organization.OrganizationDetail.OrganizationStartYear; } } response.Close(); return(dnbProfile); } catch (JsonSerializationException jex) { _ErrorMessage = "Json De-serialization exception. " + jex.Message; return(null); } catch (WebException wex) { HttpWebResponse resp = (HttpWebResponse)wex.Response; _ErrorMessage = resp.StatusCode.ToString() + " " + resp.StatusDescription; return(null); } catch (Exception ex) { _ErrorMessage = ex.Message + " | " + ex.StackTrace + " | " + ex.Source; return(null); } }