1

I am new to FORGE API development and I'm trying to develop a console application to manage data with FORGE API,These are the steps I have followed so far

1.I have successfully registered an APP on FORGE

2.Then I have acquired a OAuth token using 2-legged authorization.

3.After that I have successfully created a bucket on FORGE to upload my files

4.Finally I tried to upload a small text file to the bucket and it worked,but when I try to upload a revit file (around 18 MB) its getting an exception "More than one error".

This is the code I'm using to upload the file

            string filePath = @"C:\Users\Administrator\Desktop\Demo revit file\sample.rvt";
            string url = "https://developer.api.autodesk.com/oss/v2/buckets/mybucket/objects/sample.rvt";
            using (var client = new HttpClient())
            {



                client.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", AccessToken);        
                var response= client.PutAsync(url, new StreamContent(File.OpenRead(filePath))).Result.EnsureSuccessStatusCode();
                string res = response.ToString();
                Console.WriteLine("Response: " + res);
            }

Please help me to resolve this.

Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44
  • I would recommend you to use a higher level library to handle your REST requests. Implementing it "manually" with the basic HttpClient might require a fair piece of work in some cases. RestSharp is a pretty well established library that alleviates this task. You can take a look at my node.js sample, using the same parameters should work when using RestSharp: https://github.com/leefsmp/forge/blob/master/src/server/api/services/OssSvc.js#L189 – Felipe Sep 05 '16 at 12:21
  • @PhilippeLeefsma hi there - is there a library produced by the autodesk team which is the equivalent of Googles libraries to make end point calls? e.g. https://developers.google.com/api-client-library/? – BenKoshy Apr 28 '17 at 04:41
  • Check out our Forge SDK's at https://developer.autodesk.com/en/docs/quickstarts/v1/overview/ – Felipe Apr 29 '17 at 11:55

1 Answers1

1

Adding to Philipe comments (suggesting use RestSharp library), would also suggest you use the RESUMABLE endpoint instead, which is the best way to handle upload of large files.

Augusto Goncalves
  • 8,493
  • 2
  • 17
  • 44