【发布时间】:2014-04-04 11:43:13
【问题描述】:
我有 BOX 帐户,并且在 API 文档中
卷曲https://upload.box.com/api/2.0/files/content\ -H "授权:承载 ACCESS_TOKEN" \ -F 文件名=@FILE_NAME \ -F parent_id=PARENT_FOLDER_ID
我被这个文件名和 parent_id 卡住了如何传递文件名和 parent_id
我尝试了很多方法,但没有什么对我有用。
以下是代码:
httpWReq.Method = "POST";
httpWReq.Headers.Add("Authorization", "Bearer ");
httpWReq.ContentType = "multipart/form-data";
//{\"parent_id\":\""+parentID +"\"}
//byte[] file = File.ReadAllBytes(postData);
httpWReq.ContentLength = data.Length;
using (Stream reqStream = httpWReq.GetRequestStream())
{
reqStream.Write(data, 0, data.Length);
//reqStream.Close();
}
using (HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse())
{
//Console.WriteLine("HTTP/{0} {1} {2}", response.ProtocolVersion, (int)response.StatusCode, response.StatusDescription);
response.Close();
}
需要帮助
提前致谢
【问题讨论】:
-
您好 Vaibhav,您能提供一些您尝试过的代码吗?谢谢!
-
嗨 @JohnHoerr 我无法传递文件和 parentFolderID 它会抛出错误的请求错误。
标签: box-api