cancel
Showing results for 
Search instead for 
Did you mean: 
mdc
Level 8
Report Inappropriate Content
Message 1 of 5

web gateway rest interface

Jump to solution

    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">

<listEntry>

<entry>ooaae.3322.org</entry>

<description />

</listEntry>

</content>

</entry>

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

1 Solution

Accepted Solutions
jscholte McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 2 of 5

Re: web gateway rest interface

Jump to solution

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?

~Best,

Jon

View solution in original post

4 Replies
jscholte McAfee Employee
McAfee Employee
Report Inappropriate Content
Message 2 of 5

Re: web gateway rest interface

Jump to solution

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?

~Best,

Jon

View solution in original post

mdc
Level 8
Report Inappropriate Content
Message 3 of 5

Re: web gateway rest interface

Jump to solution

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
mdc
Level 8
Report Inappropriate Content
Message 4 of 5

Re: web gateway rest interface

Jump to solution

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

Re: web gateway rest interface

Jump to solution

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";

}

Best,

Andre

You Deserve an Award
Don't forget, when your helpful posts earn a kudos or get accepted as a solution you can unlock perks and badges. Those aren't the only badges, either. How many can you collect? Click here to learn more.

Community Help Hub

    New to the forums or need help finding your way around the forums? There's a whole hub of community resources to help you.

  • Find Forum FAQs
  • Learn How to Earn Badges
  • Ask for Help
Go to Community Help

Join the Community

    Thousands of customers use the McAfee Community for peer-to-peer and expert product support. Enjoy these benefits with a free membership:

  • Get helpful solutions from McAfee experts.
  • Stay connected to product conversations that matter to you.
  • Participate in product groups led by McAfee employees.
Join the Community
Join the Community