3 Replies Latest reply on Nov 11, 2013 8:58 AM by Jon Scholten

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

    wvcain

      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=poll o

      <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/log</id><title>File listing</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0- B10B-001E67089550/log?page=1&pageSize=9" rel="current"/><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0- B10B-001E67089550/log?page=1&pageSize=9" rel="first"/><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0- B10B-001E67089550/log?page=1&pageSize=9" 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/log/audit/" rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>debug/</id><title>deb ug</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0- B10B-001E67089550/log/debug/" 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/log/migration/" rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>mobile-device-certifi cates/</id><title>mobile-device-certificates</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0- B10B-001E67089550/log/mobile-device-certificates/" rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>mwg-errors/</id><titl e>mwg-errors</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0- B10B-001E67089550/log/mwg-errors/" 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/log/scheduled-jobs/" rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>system/</id><title>sy stem</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0- B10B-001E67089550/log/system/" rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>update/</id><title>up date</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0- B10B-001E67089550/log/update/" rel="self" type="application/atom+xml;type=feed"/></entry><entry><id>user-defined-logs/</i d><title>user-defined-logs</title><link href="http://gwctfp01.cts.wa.gov:4711/Konfigurator/REST/appliances/B8F7138C-0E44-11E0- B10B-001E67089550/log/user-defined-logs/" 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/list