Exemple #1
0
        private static void TryPostingUserToAPI(SampleUser user)
        {
            var json = JsonConvert.SerializeObject(user);

            var request = new StringContent(json, Encoding.UTF8, "application/json");

            var response     = http.PostAsync(url, request);
            var httpResult   = response.Result;
            var content      = httpResult.Content;
            var resultString = content.ReadAsStringAsync().Result;

            Console.WriteLine("Here's what came back:");
            Console.WriteLine(JsonConvert.DeserializeObject(resultString, typeof(object)));
        }
Exemple #2
0
        private static void GatherInformationAboutUser(out SampleUser user)
        {
            Console.WriteLine("Lets start by entering some of your information");

            user = new SampleUser();

            Console.WriteLine("First Name:");
            user.FirstName = Console.ReadLine();
            Console.WriteLine("Middle Name:");
            user.MiddleName = Console.ReadLine();
            Console.WriteLine("Last Name:");
            user.LastName = Console.ReadLine();
            Console.WriteLine("Phone:");
            user.Phone = Console.ReadLine();
            Console.WriteLine("Email Address:");
            user.Email = Console.ReadLine();

            return;
        }