title: Python: ServiceDesk PLus Servlet API
body: <p>I am new to programming in Python and am writing a script for my company. We use <a href="http://www.manageengine.com/products/service-desk/help/adminguide/index.html" rel="nofollow">ServiceDesk Plus</a> which uses Servlet API. I want to write a script that will auto create/close tickets upon alarms from Solarwinds. </p>
  
  <p>I cannot figure out the syntax for auto creating a ticket using the servlet API in python. Here is what I have (that does not work):</p>
  
  <pre><code>url = 'http://localhost:6970/servlets/RequestServlet/' 
  params = urllib.urlencode({
    'operation': 'AddRequest',
  })
  response = urllib2.urlopen(url, params).read()
  </code></pre>
  
  <p>Any help would be very appreciated. </p>
  
  <p>EDIT: </p>
  
  <p>I tried what James recommended with no luck. here is what my script looks like using that advice. </p>
  
  <pre><code>import urllib
  import urllib2
  
  url = 'http://localhost:6970/servlets/RequestServlet/' 
  params = urllib.urlencode({
      'operation': 'AddRequest',
      'username': 'lou',
      'password': 'lou',
      'requester': 'Sean Adams',
      'subject': 'Test Script Req',
      'description': 'TESTING!!!!!!',
      })
  request = urllib2.Request('http://localhost:6970/servlets/RequestServlet/' ,params)
  response = urllib2.urlopen(request) 
  </code></pre>
  
  <p>The errors:</p>
  
  <pre><code>C:\Users\lou\Desktop&gt;python helpdesk2.py
  Traceback (most recent call last):
    File "helpdesk2.py", line 24, in &lt;module&gt;
      response = urllib2.urlopen(request)
    File "C:\Python27\lib\urllib2.py", line 126, in urlopen
      return _opener.open(url, data, timeout)
    File "C:\Python27\lib\urllib2.py", line 400, in open
      response = meth(req, response)
    File "C:\Python27\lib\urllib2.py", line 513, in http_response
      'http', request, response, code, msg, hdrs)
    File "C:\Python27\lib\urllib2.py", line 438, in error
      return self._call_chain(*args)
    File "C:\Python27\lib\urllib2.py", line 372, in _call_chain
      result = func(*args)
    File "C:\Python27\lib\urllib2.py", line 521, in http_error_default
      raise HTTPError(req.get_full_url(), code, msg, hdrs, fp)
  urllib2.HTTPError: HTTP Error 404: /servlets/RequestServlet/
  </code></pre>