cancel
Showing results for 
Search instead for 
Did you mean: 
wvcain
Level 7

MWG rest interface, python, "/list" method not working but other (file, log, system, logon, logoff) work OK.

Jump to solution

Long story short,  I have it working for everything but list.  List was the reason that I looked into this.  Help greatly apprecated.

Using version 7.3.2.3.0

First my configuration, then my test and result (fail, error 404 when trying to retrieve the list)

I enabled rest on both https and http.  Using http for testing.

userInterface.png

I have configured a role with all rights and enable the REST-Interface for the role.

role.png

I created a user and assigned the role to the user. 

Using a python script to drive the test (follows), I log on, get some data try to get the list data which fails and log off.. The results follow as well.  You will see the success (200) and the failure (404 - Not Found)

So my fine community members, what the heck is going on. 

'''

Created on Nov 8, 2013

@author: wvcain

Script to test MWG REST interface

'''

# todo: make HTTPS work

# todo: change the auth to header w/ basic auth.

# doing: get the list working

import requests

if __name__ == '__main__':

    # logon

    url = "HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/login"

    p = {"userName":"marco", "pass":"pollo"}

    s = requests.Session()

    r = s.post(url, params=p)

    print(r.url)

    print(r.text)

    print(r.headers)

    print(r.status_code)

    print(s.cookies)

    # get the appliance IDs (returns the only one.. <id>b8f7138c-0e44-11e0-b10b-001e67089550</id>)

    url = "HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances"

    print(url)

    r = s.get(url)

    print(r.status_code)

    print(r.text)

    # Get the logs

    print('======================================')

    p = {"type":"string"}

    url = "HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/b8f7138c-0e44-11e0-b10b-001e67089550/log"

    print(url)

    r = s.get(url)

    print(r.status_code)

    print(r.text)

    # Get the lists (FAILING)

    print('======================================')

    p = {"type":"string"}

    REST = "HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/b8f7138c-0e44-11e0-b10b-001e67089550/"

    url = "HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/b8f7138c-0e44-11e0-b10b-001e67089550/list"

    print(url)

    r = s.get(url)

    print(r.status_code)

    print(r.text)

    # ALL DONE, log out

    url = "HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/logout"

    r = s.post(url)

And the output:

pydev debugger: starting

HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/login?userName=marko&pass=pollo

<entry><content>502DC87B866F3B63334CD8CFBE425ACE</content></entry>

CaseInsensitiveDict({'transfer-encoding': 'chunked', 'set-cookie': 'JSESSIONID=502DC87B866F3B63334CD8CFBE425ACE; Path=/Konfigurator', 'x-mwg-rest-version': '1', 'server': 'mwg-ui', 'date': 'Sun, 10 Nov 2013 00:28:08 GMT', 'x-mwg-ui-version': '7.3.2.3.0', 'content-type': 'application/atom+xml'})

200

<<class 'requests.cookies.RequestsCookieJar'>[<Cookie JSESSIONID=502DC87B866F3B63334CD8CFBE425ACE for gwctfp01.cts.wa.gov/Konfigurator>]>

HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances

200

<feed><id>http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances</id><title>File listing</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances?page=1&pageSize=1" rel="current"/><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances?page=1&pageSize=1" rel="first"/><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances?page=1&pageSize=1" rel="last"/><entry><id>b8f7138c-0e44-11e0-b10b-001e67089550</id><title>gwctfp01</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550" rel="self"/></entry></feed>

======================================

HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/b8f7138c-0e44-11e0-b10b-001e67089550/log

200

<feed><id>http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo...</id><title>File listing</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="current"/><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="first"/><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="last"/><entry><id>audit/</id><title>audit</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>debug/</id><title>debug</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>migration/</id><title>migration</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>mobile-device-certificates/</id><title>mobile-device-certificates</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>mwg-errors/</id><title>mwg-errors</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>scheduled-jobs/</id><title>scheduled-jobs</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>system/</id><title>system</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>update/</id><title>update</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>user-defined-logs/</id><title>user-defined-logs</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0-B10B-001E67089550/lo..." rel="self" type="application/atom+xml;type=feed"/></entry></feed>

======================================

HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/b8f7138c-0e44-11e0-b10b-001e67089550/list

404

null for uri: http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/b8f7138c-0e44-11e0-b10b-001e67089550/li...

0 Kudos
1 Solution

Accepted Solutions
eelsasser
Level 15

Re: MWG rest interface, python, "/list" method not working but other (file, log, system, logon, logoff) work OK.

Jump to solution

It looks like the help pages are wrong.

Lists are not appliance specific. It doesn't need the /appliance/UUID in the URI.

Try:

url = HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/list

0 Kudos
3 Replies
eelsasser
Level 15

Re: MWG rest interface, python, "/list" method not working but other (file, log, system, logon, logoff) work OK.

Jump to solution

It looks like the help pages are wrong.

Lists are not appliance specific. It doesn't need the /appliance/UUID in the URI.

Try:

url = HTTP://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/list

0 Kudos
wvcain
Level 7

Re: MWG rest interface, python, "/list" method not working but other (file, log, system, logon, logoff) work OK.

Jump to solution

Thanks for the quick response!  I have marked your answer spot on.

The doc is clearly wrong (Product Guide, Revision A, McAfee Web Gateway 7.3, pg 337).  Should I open a bug report or will you, as a McAfee SME do so?  Happy to do it, just don't want to duplicate effort.

Given that you adminster many appliances from any one of the appliances in  acluster, it is obvious that you don't need an device ID to access the lists.  tried /appliance/list but got a 404.  Should have keep going.

Thanks again.

Bill Cain

0 Kudos
McAfee Employee

Re: MWG rest interface, python, "/list" method not working but other (file, log, system, logon, logoff) work OK.

Jump to solution

Hi Bill,

I think this is fixed in the latest version of the product guide 7.4, I had filed something on it already.

https://kc.mcafee.com/agent/index?page=content&id=PD24752

... looks like some of the references are fixed... some are not, I'll get the rest looked at.

If you run into any other hurdles let us know.

Best,

Jon

0 Kudos