title: RESTFUL POST with Python request to Glassfish Server
body: <p>I'm having a difficulty trying to make a Python REST POST to a  webservice running on Glassfish. I have verified that POST works ok using CURL but having no luck with Python.</p>
  
  <p><strong>Here is the CURL request that works ok.</strong></p>
  
  <pre><code>curl -X POST -H "Content-Type: application/json" -d '{"id":1,"lastname":"smith"}' 
    http://192.168.0.20:8080/field1/resources/com.field1entity.field1
  </code></pre>
  
  <p><strong>Here is the Python code to make the POST request</strong></p>
  
  <pre><code>import urllib
  import httplib2
  
  def call():
  http = httplib2.Http()
  
  url = 'http://192.168.0.20:8080/field1/resources/com.field1entity.field1'
  
  params = urllib.urlencode({"id":11111,"lastname":"oojamalip"})
  
  response, content = http.request(url, 'POST', params, headers={'Content-type':'application/json'})
  print "lets stop here to have a looksy at the variables"                               
  print content
  
  if __name__ == '__main__':
  
  namesPage = call()
  print namesPage
  </code></pre>
  
  <p><strong>Output from console,</strong> </p>
  
  <blockquote>
    <p>Unexpected character ('l' (code 108)): expected a valid value (number, String, array, object, 'true', 'false' or 'null')
     at [Source: org.apache.catalina.connector.CoyoteInputStream@18f494d; line: 1, column: 2]</p>
  </blockquote>
  
  <p>Hope someone can shed some light on the problem.</p>
  
  <p>thanks
  Nick</p>