0

I have BOX account and in API document

curl https://upload.box.com/api/2.0/files/content \ -H "Authorization: Bearer ACCESS_TOKEN" \ -F filename=@FILE_NAME \ -F parent_id=PARENT_FOLDER_ID

I am stuck with this filename and parent_id how to pass the filename and parent_id

i have tried lots of way, but nothing is working for me.

Following is the code:

        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();

        }

Need Help

Thanks in Advance

2
  • Hi Vaibhav, can you include some of the code that you've tried? Thanks! Commented Apr 4, 2014 at 12:56
  • Hi @JohnHoerr i am not able to pass the File and the parentFolderID it throw bad request error. Commented Apr 6, 2014 at 8:41

1 Answer 1

1

Vaibhav,

Please see example of how official Box C# SDK is doing upload: https://github.com/box/box-windows-sdk-v2/blob/master/Box.V2/Managers/BoxFilesManager.cs

Is there any reason why you don't want to use Box Windows SDK?

Sign up to request clarification or add additional context in comments.

1 Comment

The Box.com sdk uses several projects that will not load unless you are developing in a Windows 8.1 environment. The SDk presents extremely robust objects and methods and combined with a limited selection of projects to explore along with .net framework deprecation, it becomes extremely intimidating especially considering that all those objects are are wrappers for straight calls you can make yourself. Combined with box api documentation that lacks context for people completely unfamiliar with the entire process and OAuth, the entire process can be quite difficult to follow, at best.

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.