public string patchClypItUpload(MainWindow.ClypSession Clyp, ClypUploadResponse Response) { using (var client = new HttpClient()) { MultipartFormDataContent content = new MultipartFormDataContent(); Dictionary <string, string> formData = new Dictionary <string, string>() { { "title", trackTitle.Text }, { "description", trackDescription.Text } }; if (publicButton.Foreground == new SolidColorBrush(Colors.White)) { // Must be public // formData.Add("status", "Public"); } else { // Must be private then // formData.Add("status", "Private"); } client.DefaultRequestHeaders.TryAddWithoutValidation("postman-token", "f6065275-baf8-91a9-e816-188061ac03a1"); client.DefaultRequestHeaders.TryAddWithoutValidation("cache-control", "no-cache"); client.DefaultRequestHeaders.TryAddWithoutValidation("authorization", "Bearer " + Clyp.access_token); client.DefaultRequestHeaders.TryAddWithoutValidation("x-client-type", "WebAlfa"); client.DefaultRequestHeaders.TryAddWithoutValidation("content-type", "application/x-www-form-urlencoded; charset=UTF-8"); return(client.PatchAsync("https://api.clyp.it/" + Response.AudioFileId, content).Result.Content.ReadAsStringAsync().Result); } }
private void saveButton_Click(object sender, RoutedEventArgs e) { Task.Factory.StartNew(() => { postResult = postToClypIt(Clyp, filepath, false); }).Wait(); ClypUploadResponse Response = JsonConvert.DeserializeObject <ClypUploadResponse>(postResult); if (Response.Successful) { Clipboard.SetText(patchClypItUpload(this.Clyp, Response)); System.Windows.Forms.MessageBox.Show("Test"); } }