Esempio n. 1
0
        public Vin decodeVIN(string VIN)
        {
            Vin decodedVehicleVINInfo = new Vin();

            try
            {
                var uri = new Uri(string.Format("https://vpic.nhtsa.dot.gov/api/vehicles/DecodeVin/" + VIN + "?format=json", string.Empty));

                HttpClient aapHttpClient = new HttpClient()
                {
                    MaxResponseContentBufferSize = 2147483647,
                    Timeout = new System.TimeSpan(0, 0, 15) // 15 second timeout
                };

                HttpResponseMessage response = null;
                response = aapHttpClient.GetAsync(uri).Result;

                if (response.IsSuccessStatusCode)
                {
                    var vResponseContent = response.Content.ReadAsStringAsync().Result;
                    decodedVehicleVINInfo = Vin.FromJson(vResponseContent);
                }
            }
            catch (System.Exception ex)
            {
                //await Application.Current.MainPage.DisplayAlert("", "Error creating new customer " + ex.Message.ToString(), "OK");
            }

            return(decodedVehicleVINInfo);
        }