Esempio n. 1
0
        public static async Task CreateTaskToTeam(string videoId, string languageCode, TaskType tt, string teamSlug)
        {
            using (var client = new HttpClient())
            {
                TaskSummary ts = new TaskSummary()
                {
                    VideoId      = videoId,
                    LanguageCode = languageCode,
                    TaskType     = Enum.GetName(tt.GetType(), tt)
                };
                client.BaseAddress = new Uri(baseAddress);
                client.DefaultRequestHeaders.Add("X-api-username", userName);
                client.DefaultRequestHeaders.Add("X-api-key", apiKey);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = await client.PostAsJsonAsync("teams/" + teamSlug + "/tasks/", ts);

                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("Create task success ");
                }
                else
                {
                    Console.WriteLine("Create task failure: " + response.StatusCode);
                }
            }
        }
        public static async Task CreateTaskToTeam(string videoId, string languageCode, TaskType tt, string teamSlug)
        {
            using (var client = new HttpClient())
            {
                TaskSummary ts = new TaskSummary()
                {
                    VideoId = videoId,
                    LanguageCode = languageCode,
                    TaskType = Enum.GetName(tt.GetType(), tt)
                };
                client.BaseAddress = new Uri(baseAddress);
                client.DefaultRequestHeaders.Add("X-api-username", userName);
                client.DefaultRequestHeaders.Add("X-api-key", apiKey);
                client.DefaultRequestHeaders.Accept.Clear();
                client.DefaultRequestHeaders.Accept.Add(new MediaTypeWithQualityHeaderValue("application/json"));
                HttpResponseMessage response = await client.PostAsJsonAsync("teams/"+teamSlug+"/tasks/", ts);
                if (response.IsSuccessStatusCode)
                {
                    Console.WriteLine("Create task success ");
                }
                else Console.WriteLine("Create task failure: " + response.StatusCode);

            }
        }