Created
December 12, 2019 07:57
-
-
Save brianhdk/5877fbc2b87d2ffcd7e90a33a436b638 to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| async Task Main() | |
| { | |
| using (var httpClient = new HttpClient()) // store instance, dispose when your application shuts down | |
| { | |
| httpClient.BaseAddress = new Uri("https://vertica-xmas2019.azurewebsites.net"); | |
| var participateRequest = new ParticipateRequest | |
| { | |
| FullName = "", | |
| EmailAddress = "", | |
| SubscribeToNewsletter = true | |
| }; | |
| HttpResponseMessage apiResponse = await httpClient.PostAsJsonAsync("/api/participate", participateRequest); | |
| if (!apiResponse.IsSuccessStatusCode) // if the request fails, output the raw response | |
| throw new InvalidOperationException($"{apiResponse.StatusCode}: {(await apiResponse.Content.ReadAsStringAsync())}"); | |
| var participateResponse = await apiResponse.Content.ReadAsAsync<ParticipateResponse>(); | |
| participateResponse.Dump(); | |
| } | |
| } | |
| public class ParticipateRequest | |
| { | |
| public string FullName { get; set; } | |
| public string EmailAddress { get; set; } | |
| public bool SubscribeToNewsletter { get; set; } | |
| } | |
| public class ParticipateResponse | |
| { | |
| public Guid Id { get; set; } | |
| public Credentials Credentials { get; set; } | |
| } | |
| public class Credentials | |
| { | |
| public string Username { get; set; } | |
| public string Password { get; set; } | |
| } |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment