Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Welcome To Ask or Share your Answers For Others

Categories

0 votes
1.5k 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 Reply

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


与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…
OGeek|极客中国-欢迎来到极客的世界,一个免费开放的程序员编程交流平台!开放,进步,分享!让技术改变生活,让极客改变未来! Welcome to OGeek Q&A Community for programmer and developer-Open, Learning and Share
Click Here to Ask a Question

...