public StandardResponseViewModel BugsBehaviorRESTCall(string project, TeamSettings vm) { var response = new StandardResponseViewModel(); using (var client = new HttpClient()) { //client.BaseAddress = new Uri(_apiurl); client.DefaultRequestHeaders.Accept.Clear(); client.DefaultRequestHeaders.Accept.Add(new System.Net.Http.Headers.MediaTypeWithQualityHeaderValue("application/json")); client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Basic", _login); var patchValue = new StringContent(JsonConvert.SerializeObject(vm), Encoding.UTF8, "application/json"); var method = new HttpMethod("PATCH"); var request = new HttpRequestMessage(method, _apiurl + project + "/_apis/work/teamsettings?api-version=2.0-preview.1") { Content = patchValue, }; var result = client.SendAsync(request).Result; if (result.IsSuccessStatusCode) { response.Success = true; } else { response.Success = false; response.Message = "Error during rest call: " + result.ReasonPhrase; } return(response); } }
private static void ExportOne(string processId, string destinationFolder, string name) { if (!Directory.Exists(destinationFolder)) { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("invlaid path argument: folder not found"); return; } Console.ForegroundColor = ConsoleColor.White; if (name.Equals(String.Empty)) { Console.Write("Exporting Process '" + processId + "': "); } else { Console.Write("Exporting Process '" + name + "': "); } Processes process = new Processes(_appConfig); StandardResponseViewModel response = process.Export(processId, destinationFolder, name); if (response.Success) { Console.ForegroundColor = ConsoleColor.Green; Console.WriteLine("Success"); } else { Console.ForegroundColor = ConsoleColor.Red; Console.WriteLine("Failed: " + response.Message); } process = null; }
public StandardResponseViewModel Export(string processId, string path, string name) { //processId = ADCC42AB-9882-485E-A3ED-7678F01F66BC Byte[] bytes = this.GetProcessExportDataRESTCall(processId); StandardResponseViewModel response = new StandardResponseViewModel(); if (bytes != null) { //Byte[] bytes = Convert.FromBase64String(vm.data); File.WriteAllBytes(@path + @"\" + name + ".zip", bytes); response.Success = true; response.Message = name + ".zip file was successfull created"; } else { response.Success = false; response.Message = "error getting data from rest api for '" + processId + "'"; } return(response); }