Rest end point's POST method not working in client (python) but same rest api works with soapUI -


accept-encoding: gzip,deflate integrating rest based web services program. rest services tested soapui. rest end points working fine. when integrate rest services python based client program facing issue post request. have tried using urllib2, requests, httplib modules..

urllib2 implementation

import urllib2  import urllib  url = "https://serverip.com/webapi/object1/" values = {         "owner": 1,         "parent": 1,         "region": 7,         "pod_identifier": "ememaster1",         "type": "s",         "number": 1,         "description": "testtttt",     }    data  = urllib.urlencode(values)  req = urllib2.request(url)  req.add_data(data) req.add_header("authorization", "token as123131231231312312321asddasd43532y5456#$%#$")  response = urllib2.urlopen(req) res = response.read() print res 

result

file "tester.py", line 24, in <module>     response = urllib2.urlopen(req)   file "/usr/lib64/python2.6/urllib2.py", line 126, in urlopen     return _opener.open(url, data, timeout)   file "/usr/lib64/python2.6/urllib2.py", line 397, in open     response = meth(req, response)   file "/usr/lib64/python2.6/urllib2.py", line 510, in http_response     'http', request, response, code, msg, hdrs)   file "/usr/lib64/python2.6/urllib2.py", line 435, in error     return self._call_chain(*args)   file "/usr/lib64/python2.6/urllib2.py", line 369, in _call_chain     result = func(*args)   file "/usr/lib64/python2.6/urllib2.py", line 518, in http_error_default     raise httperror(req.get_full_url(), code, msg, hdrs, fp) urllib2.httperror: http error 400: bad request 

i facing same issue while using requests , httplib2 soapui request works fine.

can me understand problem?

/shan


Comments

Popular posts from this blog

c# - How to get the current UAC mode -

postgresql - Lazarus + Postgres: incomplete startup packet -