我正在尝试通过 POST 请求将文件上传到TestFlight Api。我尝试尽可能简单地做到这一点,但我仍然收到错误 500。
HttpWebRequest request = WebRequest
.Create('http://testflightapp.com/api/builds.json') as HttpWebRequest;
request.KeepAlive = false;
request.Headers.Add("api_token", "####");
request.Headers.Add("team_token", "####");
request.Headers.Add("notes", "notes");
request.ContentType = "multipart/form-data";
request.Method = WebRequestMethods.Http.Post;
byte[] messageArray = File.ReadAllBytes(filePath);
request.ContentLength = messageArray.Length;
Stream requestStream = request.GetRequestStream();
requestStream.Write(messageArray, 0, messageArray.Length);
requestStream.Close();
WebResponse response = request.GetResponse();
StreamReader responseReader = new StreamReader(response.GetResponseStream());
string result = responseReader.ReadToEnd();
responseReader.Close();
response.Close();
return result;
我做错了什么?