2 Replies Latest reply on Nov 11, 2013 7:57 AM by jameswright

    Batch Operations with REST API?

    msoltow

      Is there a way to perform batch operations with the REST API?  This document (Using Batch Operations with the V3 API) seems to suggest that there is, but provides no details on how to perform the operations, aside from the basic inputs and outputs (and even those are only for GET requests...where does the body go for POST requests?).

       

      Does anyone have a more complete example for how to perform batch operations?

       

      Thank you very much!

        • Re: Batch Operations with REST API?
          maxime.duval@lacapitale.com

          I would also like to know if its possible to perform batch operations with the REST API. Right now we are using a script to empty some security groups and then fill them again with the right users. This script runs daily, and as our community grows, it take a really long time only to remove users from security groups (about 1,5 hours only for removing ~ 1500 users from 5 security groups). This is really long to empty 5 security groups!! I think I would probably be faster manually.

           

          Is there a way to send those request in batch in order to make it faster (or even better, empty them with a single request!!!).

           

          I know this is not the best way to do, and we will look into managing the users in our security groups more elegantly in order to drop the number of request made, but still, I would really like to know if there is a way to batch similar request.

           

          From what I've seen from Using Batch Operations with the V3 API, it doesnt seem to be what we are looking for (its more to make a sequence of call and re-use parameters from previous calls).

           

          Thanks!

          Maxime

          • Re: Batch Operations with REST API?
            jameswright

            I believe you just add a body property to the request and change the method to POST or DELETE or PUT depending on your operation..... As you can see its a JSON Array so you can mix and match your operations and I believe it runs in order of the 'array'..

             

            [{

                    "key": "content",

                    "request": {

                        "method": "POST",

                        "endpoint": "/api/core/v3/contents",

                        "body": {

                            "content": {

                                "type": "text/html",

                                "text": "<body><p>Here is some content</p></body>"

                            }

                        }

                    }

            },

            {      "key":"person",

                    "request": {

                           "method":"DELETE",

                           "endpoint":"/api/core/v3/people/23"

                     }

            },

            {      "key":"person2",

                    "request": {

                           "method":"DELETE",

                           "endpoint":"/api/core/v3/people/1023"

                     }

            }]

             

            But the documentation is lacking.. So good luck. If you just pop open fiddler and fiddler around for a few minutes you will figure it out. Also, according to the docs, they use JSONPath, and allow for cross referencing other previous operations in the batch process in future operations... I haven't messed with this yet.

             

            - james