How can I download a file from an Autodesk A360 bucket that I created? The file is a Revit project file and I used 2-legged OAuth for authorization.

- 232,980
- 40
- 330
- 338

- 27
- 6
-
Oh and i need to do this in a winform if possible! – jockathon junior Oct 13 '16 at 11:57
-
and did i mention C# would be nice, i just found out about json the other night, the one without the mask and now i am wondering if this is essential to get the handle of my project from the forge cloud? – jockathon junior Oct 13 '16 at 13:10
2 Answers
You need to use 3 legged authentication to access files from A360, because you need the approval of the user whose account you are accessing - the user is the 3rd leg. If you are trying to access files from your own application's private bucket on OSS then you do not need a user's approval because the bucket belongs to your app and not a user.
As a side note, in case of trying to access BIM 360 files (in case that's what you are talking about) using the Data Management API, then for the time being you need to use 2 legged authentication but your app needs to be manually approved by us.
2-legged vs 3-legged authentication is covered by Augusto's webcast: Introduction to oAuth and Data Management API

- 1,700
- 1
- 9
- 14
-
Hi Philippe, I used the tuturial here to upload to ....? http://the360view.typepad.com/blog/2015/02/autodesk-view-and-data-api-intro-overview.html – jockathon junior Oct 14 '16 at 12:17
-
Where my buckets and their contents are I am not completely sure now. I thought it was a360 that was accepting my uploads to. The above link to the oauth 2 legged and create a bucket and upload tutorial. I am only looking initially to store files for collaboration and upload/ download through a winform with .net – jockathon junior Oct 14 '16 at 12:21
-
yes, after watching Augusto's tutorial I think I have upload rvt files sucsessfully to a bucket in the OSS. Here is what I am attempting to do. In my .net winform upload a file into a project named bucket transparently signing in with no login and hence 2-legged. The user than can select a project and download any files in that bucket or get a list of files from that bucket and download again all in the same winform – jockathon junior Oct 14 '16 at 14:09
-
public static void Download(string accessToken, string bucketName, string fileName, byte[] fileData) { // (1) Build request var client = new RestClient(); client.BaseUrl = new System.Uri(baseApiUrl); // Set resource/end point var request = new RestRequest(); request.Resource = "oss/{version}/buckets/{bucketname}/objects/{filename}"; request.Method = Method.GET; } – jockathon junior Oct 15 '16 at 02:54
-
So can I use Method.Get, to retrieve a Uniform Resource Name (URN) to download the .rvt file that i uploaded? – jockathon junior Oct 15 '16 at 02:56
-
Also what is the file size limit for upload and then download from the object storage service? – jockathon junior Oct 15 '16 at 02:57
-
public static void Download(string accessToken, string bucketName, string fileName, string strPath) { // (1) Build request var client = new RestClient(); client.BaseUrl = new System.Uri(baseApiUrl); // Set resource/end point var request = new RestRequest(); request.Resource = "oss/{version}/buckets/{bucketname}/objects/{filename}"; request.Method = Method.GET; client.DownloadData(request).SaveAs(@"G:\" + fileName); } – jockathon junior Oct 15 '16 at 04:35
-
I tried the above to download the file at the bucket I uploaded to from the same application. What I really download is a text file, if you change the extension, it says service unavailable. – jockathon junior Oct 15 '16 at 04:38
-
oops spoke to soon i forgot the token! now i need to get something worthwhile for coordination up there – jockathon junior Oct 15 '16 at 04:42
-
I don't get a bucket key after attempting to create a bucket in when i change v1 to v2...
see below
public static string GetBucket(string accessToken, string bucketKey, string policy) {
// (1) Build request
var client = new RestClient();
client.BaseUrl = new System.Uri(baseApiUrl);
// Set resource/end point
var request = new RestRequest();
request.Resource = "oss/v1/buckets";
request.Method = Method.GET;
// Add headers
request.AddHeader("Authorization", "Bearer " + accessToken);
request.AddHeader("Content-Type", "application/json"); // MH: skipping this works.
// Add JSON body. in simplest form.
request.AddJsonBody(new { bucketKey = bucketKey, policy = policy });
// (2) Execute request and get response
IRestResponse response = client.Execute(request);
//TaskDialog.Show("create bucket", response.StatusDescription);
// Save response. This is to see the response for our learning.
m_lastResponse = response;
TaskDialog.Show("response", m_lastResponse.ToString());
// Get the key = bucket name
string key = "";
if (response.StatusCode == HttpStatusCode.OK)
{
JsonDeserializer deserial = new JsonDeserializer();
OssBucketsResponse bucketsResponse = deserial.Deserialize<OssBucketsResponse>(response);
key = bucketsResponse.key;
}
return key; // the bucket name
}

- 27
- 6
-
There are changes between the responses coming from v1 and v2 API. So I guess the deserialization will fail with the old object of OssBucketsResponse. The best thing would be if you used a tool like Postman to check what exact response you get back with the various API's and modify the code and declared classes in it accordingly. – Adam Nagy Nov 08 '16 at 19:16