473,471 Members | 1,970 Online
Bytes | Software Development & Data Engineering Community
Create Post

Home Posts Topics Members FAQ

How to upload a file in a BOX Storage Folder using Box Api ?

1 New Member
Expand|Select|Wrap|Line Numbers
  1. public static void UploadFileRequest(string FolderID, string accesstoken)
  2.         {
  3.  
  4.             string boundary = string.Format("----------------------------{0}", DateTime.Now.Ticks.ToString("x"));
  5.             string filenamee = "C:\\Users\\Administrator\\Desktop\\Text.txt";
  6.             HttpWebRequest httpWReq = (HttpWebRequest)WebRequest.Create("https://upload.box.com/api/2.0/files/content");
  7.             ASCIIEncoding encoding = new ASCIIEncoding();
  8.             //string postData = "{\"parent\": {\"id\": \"" + ParentFolderId + "\"}}";
  9.             string kk = string.Format("filename=@{0}&parent_id={1}", filenamee, FolderID);
  10.             byte[] data = encoding.GetBytes(kk);
  11.  
  12.             httpWReq.Method = "POST";
  13.             httpWReq.Headers.Add("Authorization", "Bearer HVJfdT8ugzWoV3bQSk5XMUhQdoiuioCc");
  14.             httpWReq.ContentType = "application/json";
  15.             httpWReq.ContentLength = data.Length;
  16.  
  17.             using (Stream stream = httpWReq.GetRequestStream())
  18.             {
  19.                 stream.Write(data, 0, data.Length);
  20.             }
  21.  
  22.             HttpWebResponse response = (HttpWebResponse)httpWReq.GetResponse();//I am getting error in response there might be a possibility that body of my content is not correct
  23.  
  24.             string responseString = new StreamReader(response.GetResponseStream()).ReadToEnd();
  25.         }
PleaseHelp ,, Thankyou
Apr 2 '14 #1
0 1631

Sign in to post your reply or Sign up for a free account.

Similar topics

1
by: PeterB | last post by:
Hi! I'm using Pure ASP File Upload (http://www.asp101.com/articles/jacob/scriptupload.asp) to upload a file from a client to a server. I am testing both on a local IIS and a remote server. The...
2
by: John Regan | last post by:
Hello All I am trying to find the owner of a file or folder on our network (Windows 2000 Server) using VB.Net and/or API. so I can search for Folders that don't follow our company's specified...
2
by: gvindia | last post by:
Hai, Please help me. How can lock file or folder using c/c++ in windows. regards, gv.
12
by: fanoftvb | last post by:
Hi, i would like to move a selected files to a folder using vb.net. I currently have this code If File.Exists("C:\Documents and Settings\055949x\transfer\text.txt") And Not...
0
by: iahmed | last post by:
Is anybody works on StreamLoad API using gSOAP protocol. I have some problem in uploading the file on StreamLoad server.
5
by: TC | last post by:
Hey All, I'm trying to upload files via FTP and I'm using FtpWebRequest and WebClient. Unfortunately, I'm receiving a "Not Logged In" error. I know that others have seen this as I've seen...
7
by: dragiton | last post by:
SA Upload SQL Database variable types (image upload and storage) I am having trouble with the SA Upload utility. The following code used to work correctly. However, I lost my database and had to...
1
by: mirasol | last post by:
i am new here,i just want to ask question about uploading file with textbox using mysql and php, i used the codes given by some member and my problem is i dont know how to add textbox and i want it...
11
NeoPa
by: NeoPa | last post by:
Overview It is often required to prompt the operator of an Access project to select a file or folder. Sure, it's possible to allow them to type it in freehand, or even paste it in from another...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
jinu1996
by: jinu1996 | last post by:
In today's digital age, having a compelling online presence is paramount for businesses aiming to thrive in a competitive landscape. At the heart of this digital strategy lies an intricately woven...
1
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
1
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...
0
by: conductexam | last post by:
I have .net C# application in which I am extracting data from word file and save it in database particularly. To store word all data as it is I am converting the whole word file firstly in HTML and...
0
by: adsilva | last post by:
A Windows Forms form does not have the event Unload, like VB6. What one acts like?
0
by: 6302768590 | last post by:
Hai team i want code for transfer the data from one system to another through IP address by using C# our system has to for every 5mins then we have to update the data what the data is updated ...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.