Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.4k views
in Technique[技术] by (71.8m points)

autodesk forge - 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?

question from:https://stackoverflow.com/questions/66063395/how-can-i-get-more-than-100-bucket-objects-how-can-i-list-all-the-bucket-object

与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome To Ask or Share your Answers For Others

1 Answer

0 votes
by (71.8m points)

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
Welcome to OStack Knowledge Sharing Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...