Sample Python Code

Please note: Sample code is Python 3.3. Samples for earlier versions of Python are not yet available

# To make our lives easier when sending/receiving data from a web service
# we'll use the requests library from
# This library provides a much simpler API for sending and receiving data
# than the native urllib API from Python itself.
import requests

# Setup the payload here. The structure of the payload itself will obviously
# change depending on which method/dataset combination we call and what
# parameters that method/dataset combination requires.
# Note that unlike C# and PHP, we do not prefix the XML with the POST key of apirequest=
# because in true pythonic fashion, the request library requires name/value pairs to be
# sent to it in a dictionary

xml = """<?xml version="1.0" encoding="UTF-8" ?> <data>

# form the dictionary payload here
payload = {'apirequest':xml}

# set the content type
headers = {'Content-Type': 'application/x-www-form-urlencoded'}

# make the request and assign the return data
returnData ='', data=payload, headers=headers)

# The actual XML (or JSON) data is contained within returnData.text and you can now process it
# For the purposes of this sample, we'll just dump the raw text to the screen
requestOutput = returnData.text print (sRequestOutput)