NIH | National Cancer Institute | NCI Wiki  

Error rendering macro 'rw-search'

null

Versions Compared

Key

  • This line was added.
  • This line was removed.
  • Formatting was changed.

...

Code Block
languagepython
titleSimple Python Rest Client
collapsetrue
__author__ = 'sbauer'
import urllib2

try:
    file = urllib2.urlopen('http://bmidev4:5555/cts2/resolvedvaluesets')
except urllib2.URLError, e:
    if e.code == 404:
        print("check url")
#     continue to handle other errors here
else:
    print(file.read())

 

Three code snippets that can stand alone.  Two return XML and one returns JSON.  Python must be installed on your system.  Download the third party library python-rest-client.  Add python-rest-client to the PYTHONPATH environment variable to your system.  Create a python script file and run as above.

...