4 Replies Latest reply on May 7, 2012 3:33 AM by asabban

    web gateway rest interface

    mike calvi

          is anyone using the rest interface to manage lists?  There doesnt seem to be a lot of documentation on what is available to use on it or errors.  I have seen the post on the examples (https://community.mcafee.com/message/232278#232278) but and have all that working via perl but I am getting an error when attempting to populate a list.  The list is a host based string list.



      500 Internal Server Error

      com.scur.k.shared.lists.ListEntry cannot be cast to com.scur.k.shared.lists.AbstractKonfiguratorList



      This is the XML file we are attempting to post which is causing the error.

      <entry xmlns="http://www.w3org/2011/Atom">

      <content type="application/xml">



      <description />






      Any ideas on where to look for the proper casting or xml entries?

        • 1. Re: web gateway rest interface
          Jon Scholten

          Hi Mike!


          I'm working on something cool with REST and see room for improvment in helping the user, this is probably one of them. I'll share my experience.


          To determine how a list should be populated, I was just pulling down existing lists that I've created in the GUI. Then adding entries to that list and uploading it (or emulating the response recieved).


          Attached is an example string list.


          From your example, you are missing the listType (string).


          There is a couple ways to create a new list.

          1. Specify the name and type in the POST: "$REST/list?name=newlisttype=category", this creates an empty list.

          2. Specify the name and type in the POST and include a xml with the content (this creates a list with your name and type, and with the contents you provide).

          3. Specify the name, type, and contents in the POST BODY


          Which method were you using to create the list?




          • 2. Re: web gateway rest interface
            mike calvi

            since it is essentially a blacklist and will always exist, i created it via the GUI.   I used your method of pre-populating a few domains and pulled the list.  I took that and then manipulated to include mine and after a commit (very important to remember), it works.  Attached is what I had to send to it.


            Message was edited by: mdc on 5/2/12 3:52:28 PM CDT
            • 3. Re: web gateway rest interface
              mike calvi

              I found another item to note on the XML::Simple library in perl when using the rest api.


              If the list has one element, you are the listEntry node contains a hash.


              Output from perl Data::Dumper
              $VAR1 = {
                        'listEntry' => {    <-- hash, no array first
                                       'entry' => 'http://www.badsite1.com/login.php',
                                       'description' => {}




              If there are multiple items in the list, you get an array in the listEntry node.


              $VAR1 = {
                        'listEntry' => [  <-- array reference first
                                       {  <- then a hash
                                         'entry' => 'http://www.badsite1.com/login.php',
                                         'description' => {}
                                         'entry' => 'http://test.com/waffles.php',
                                         'description' => {}


              Message was edited by: mdc on 5/4/12 9:46:58 AM CDT
              • 4. Re: web gateway rest interface

                Hi Mike,


                you are right. You can control this behaviour:


                my $ref = XMLin("test.xml", ForceArray => 1);


                By adding the "ForceArray=>1" you will get arrays with one element instead of a hash. So you could use the same code for lists with one or multiple entries.


                As an alternative you could use "ref" to check the type of the reference:


                if (ref($r) eq "HASH") {

                  print "r is a Hash";