I am trying to consume a rest service but at the moment of doing it, it sends me an error.
I leave below the code I am occupying.
import http.client
metadatos = {a:1, b:2, c:3}
conn = http.client.HTTPConnection("10.133.xxx.xxx")
conn.request("PUT", "/rest", metadatos)
resp = conn.getresponse()
print(resp.status, resp.reason)
If you make the connection but at the time of doing the PUT is where I get the error
The error you send me is the following
Traceback (most recent call last): File "C: \ Program Files \ JetBrains \ PyCharm Community Edition 2017.1.4 \ helpers \ pydev \ pydevd.py ", line 1591, in globals = debugger.run (setup ['file'], None, None, is_module) File "C: \ Program Files \ JetBrains \ PyCharm Community Edition 2017.1.4 \ helpers \ pydev \ pydevd.py ", line 1018, in run pydev_imports.execfile (file, globals, locals) # execute the script File "C: \ Program Files \ JetBrains \ PyCharm Community Edition 2017.1.4 \ helpers \ pydev_pydev_imps_pydev_execfile.py ", line 18, in execfile exec (compile (contents + "\ n", file, 'exec'), glob, loc) File "C: /Users/mxe01508121A/PycharmProjects/PublicadorFirmaAutografaDigital/PublicadorFAD.py", line 73, in conn.request ("PUT", "/ rest", metadata) File "C: \ Users \ mxe01508121A \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ http \ client.py", line 1239, in request self._send_request (method, url, body, headers, encode_chunked) File "C: \ Users \ mxe01508121A \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ http \ client.py", line 1285, in _send_request self.endheaders (body, encode_chunked = encode_chunked) File "C: \ Users \ mxe01508121A \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ http \ client.py", line 1234, in endheaders self._send_output (message_body, encode_chunked = encode_chunked) File "C: \ Users \ mxe01508121A \ AppData \ Local \ Programs \ Python \ Python36-32 \ lib \ http \ client.py", line 1064, in _send_output + b '\ r \ n' TypeError: can not concate bytes to str
I hope you can help me.
Greetings!