1 2 Previous Next 15 Replies Latest reply: Jul 31, 2013 9:00 AM by mreco RSS

    Examples of REST scripting




      can somebody show some examples of using REST scripting, like add/delete list entries or modify rules?


      best regards

        • 1. Re: Examples of REST scripting



          the documentation is still being worked on, but it should be available soon.


          To use REST there are come examples with CURL available which you can try on the command line.


          1.) Write the REST URL into a variable (easier to read later):


          export REST=http://localhost:4711/Konfigurator/REST


          2.) You need to authenticate with valid credentials. MWG will return a Cookie which you need for further requests to be authenticated:


          curl -i -c cookies.txt  -H "Authorization: Basic YWRtaW46d2ViZ2F0ZXdheQ==" -X POST "$REST/login"

          curl -i -b cookies.txt "$REST/appliances"


          3.) You can see all available lists by using


          curl -i -b cookies.txt "$REST/list"


          4.) You can create an empty list with


          curl -i -b cookies.txt -X POST "$REST/list?name=newlist&type=category"


          5.) Get a list


          curl -i -b cookies.txt "$REST/list/com.scur.type.mediatype.4532"


          6.) Get list entry


          curl -i -b cookies.txt "$REST/list/com.scur.type.mediatype.4532/entry/1"


          7.) Delete list entry


          curl -i -b cookies.txt -X DELETE "$REST/list/com.scur.type.mediatype.4532/entry/1"


          8.) Modify list entry


          curl -i -b cookies.txt -X PUT -d @listEntryRequest.xml "$REST/list/com.scur.type.regex.11347/entry/1" -H "Content-Type: application/xml"


          where "listEntryRequest.xml" is a file which contains the new entry, such as:


          <entry xmlns="http://www.w3.org/2005/Atom">

          <content type="application/xml">



            <description />





          I hope this helps. Rule modification is not yet possible as far as I know. If you need specific examples, just let me know, I will try to provide them.




          • 2. Re: Examples of REST scripting



            is it possible on this way to modify permissions for ruleset?



            • 3. Re: Examples of REST scripting

              The current implementation of of REST on MWG only allows you to do certain functions.









              Logs and file server files:

              list of directories and log files

              download log file

              delete log file

              list of files

              download file

              add file

              modify file

              delete file


              And manipulate lists. Add/Remove/Modify/etc.


              It does not provide access tot he rules or policy, other than the list contents.

              • 4. Re: Examples of REST scripting



                the retrieving and uploading of lists works on MWG 7.1.6, but if trying to delete an entry I get a parser output "org.apache.abdera.parser.stax.FOMEntry...".


                the beta 7.2.0 shows no error message but the entry still present, cannot be deleted.


                can you check this issue? Is it a bug or the "delete" requieres an another syntax?



                • 5. Re: Examples of REST scripting



                  to delete a list you just need to issue a DELETE request using the list-ID. Following the examples posted earlier it should look like this:


                  curl -i -b cookies.txt -X DELETE "$REST/list/com.scur.type.regex.4537"


                  Can you give an example of the request you are sending? So far I haven't seen the error you mentioned.





                  • 6. Re: Examples of REST scripting

                    Hello, the output attached

                    • 7. Re: Examples of REST scripting

                      Yes, that's a bug. The command is correct and should work. I can reproduce the error with MWG


                      I can't reproduce it with MWG 7.2 (which will be released fairly soon), so it seems that it's fixed. Deleting entries or the whole list worked fine in my test and after a commit the changed entries or the list was actually gone. I tested with the latest internal MWG 7.2 build, I haven't checked with the Beta build yet.


                      If you need the fix to be backported to the 7.1.6 branch, please raise a ticket with support.





                      • 8. Re: Examples of REST scripting

                        How do you log back out? In testing I end up with many many active sessions, which creates problems if you dont allow multiple logins per account. Thoughts?

                        • 9. Re: Examples of REST scripting

                          If you are using the examples set forth in the docs with curl:


                          curl -i -b cookies.txt -X POST "$REST/logout"



                          Message was edited by: eelsasser on 6/18/13 3:12:22 PM EDT
                          1 2 Previous Next