#c# #forms #multipartform-data #webrequest
#c# #формы #составная форма-данные #webrequest
Вопрос:
Привет, я пытаюсь отправить запрос с составными / данными формы.
string sURL = base_url "?action=add-torrent";
WebRequest torrent_post = WebRequest.Create(sURL);
torrent_post.ContentType = "multipart/form-data";
torrent_post.Method = "POST";
var reqparm = new System.Collections.Specialized.NameValueCollection();
byte[] bytes = System.IO.File.ReadAllBytes("one.torrent");
Debug.WriteLine(bytes[5]);
using (Stream requestStream = torrent_post.GetRequestStream())
{
requestStream.Write(bytes, 0, bytes.Length);
requestStream.Close();
}
api, который я пытаюсь отправить данные, является:
http://[iP]:[PORT]/gui/?action=add-file
This action is different from the other actions in that it uses HTTP POST instead of HTTP GET to submit data to µTorrent. The HTTP form must use an enctype of "multipart/form-data" and have an input field of type "file" with name "torrent_file" that stores the local path to the file to upload to µTorrent.
исходя из этого, единственное, чего мне не хватает, — это фактические поля ввода. как бы это реализовать? Спасибо
Комментарии:
1. Итак, в чем проблема?
2. как мне реализовать фактические поля ввода в запросе?
3. Используйте
HttpClient
MultipartFormDataContent
вместо WebRequest4. невозможно для моего приложения