1
マイコード。データを投稿した後でWebClientレスポンスを読み取る方法は? WebClient.UploadDataメソッド(String、文字列、バイト[])ここ
string uriString = "http://www.Testcom";
WebClient myWebClient = new WebClient();
string postData = "data";
myWebClient.Headers.Add("Content-Type","application/x-www-form-urlencoded");
Console.WriteLine(myWebClient.Headers.ToString());
byte[] byteArray = Encoding.ASCII.GetBytes(postData);
byte[] responseArray = myWebClient.UploadData(new
Uri(uriString),"POST",byteArray);
私は今このようなAPIプロジェクトで作成されたUploadDataとgetメソッドを呼び出します。
[HttpPost]
[Route("doc2pdf")]
public HttpResponseMessage doc2pdf(byte[] fileContent)
{
string pdfContent = string.Empty;
//if(string.IsNullOrEmpty(docContent))
//{
// var resp = Request.CreateResponse(HttpStatusCode.BadRequest,"Document content is empty.");
// return resp;
//}
if(fileContent != null || fileContent.Length > 0)
{
..logic here
}
}
問題は常にfileContent get {byte [0]}です。
は今、どのように私は、HTTP出力を読みますか。 WEBAPIにデータを送信するために