public static async Task<Repository> CreateRepository(CreateRepository createParams) { HttpClient client = GetHttpClient(); using (client) { HttpResponseMessage response = await client.PostAsJsonAsync("api/v1/repos", createParams); if (response.StatusCode != System.Net.HttpStatusCode.OK) throw new Exception(string.Format( "API Status Code {0}. Expected OK.", response.StatusCode)); return await response.Content.ReadAsAsync<Repository>(); } }
static void CreateRepository() { Console.Write("Write a name for the repository: "); string name = Console.ReadLine(); Console.Write("Write the direction of the server: "); string server = Console.ReadLine(); CreateRepository action = new CreateRepository() { Name = name, Server = server }; Repository newRepo = ApiUtils.CreateRepository(action).Result; Console.Write(string.Format("Repository {0} successfully created!", newRepo.Name)); }