Search code examples
autodesk-forgeautodeskforgeautodesk-data-management

How can I get more than 100 bucket objects? How can I list all the bucket objects?


using https://forge.autodesk.com/en/docs/data/v2/reference/http/buckets-GET/ , I can set the limit as 100 and withdraw bucket objects. But how can I get all the bucket objects in a bucket key?

HttpWebRequest request = (HttpWebRequest)WebRequest.Create("https://developer.api.autodesk.com/oss/v2/buckets/mybucketkey/objects?limit=100");
        request.Method = "Get";
        request.KeepAlive = true;
        request.ContentType = "appication/json";
        request.Headers.Add("Authorization", "Bearer my token" );


        HttpWebResponse response = (HttpWebResponse)request.GetResponse();
        string myResponse = "";
        using (System.IO.StreamReader sr = new System.IO.StreamReader(response.GetResponseStream()))
        {
            myResponse = sr.ReadToEnd();
        }

I can list 100 in this way. But I couldn't find how to list them all. Could it be related to the startAt parameter?


Solution

  • If the reply contains a "next" property then you have to use that to get the next 100 items. Keep doing that until you get all items. Yes, the startAt parameter will specify the next 100 you want to get back

    See e.g. https://github.com/Autodesk-Forge/forge-buckets-tools/blob/master/server/data.management.js#L247