Я пытаюсь вызвать команду curl, используя urllib2. Ниже приведен фрагмент кода.
with open("blueprint_response.txt", 'r') as f:
response_data = json.load(f)
Url = 'https://XXX/composition-service/api/blueprints/YYY_no_Chef'
content_header = {'Content-type':'application/json', 'Accept' : 'application/json', 'Authorization' : 'Bearer <token>'}
request = urllib2.Request(url=Url, data = response_data, headers = conten_header)
request.get_method = lambda: 'PUT'
response = urllib2.urlopen(request)
здесь я получаю следующую ошибку.
Traceback (most recent call last):
File "2.py", line 20, in <module>
response = urllib2.urlopen(request)
File "/usr/lib64/python2.7/urllib2.py", line 154, in urlopen
return opener.open(url, data, timeout)
File "/usr/lib64/python2.7/urllib2.py", line 431, in open
response = self._open(req, data)
File "/usr/lib64/python2.7/urllib2.py", line 449, in _open
'_open', req)
File "/usr/lib64/python2.7/urllib2.py", line 409, in _call_chain
result = func(*args)
File "/usr/lib64/python2.7/urllib2.py", line 1258, in https_open
context=self._context, check_hostname=self._check_hostname)
File "/usr/lib64/python2.7/urllib2.py", line 1211, in do_open
h.request(req.get_method(), req.get_selector(), req.data, headers)
File "/usr/lib64/python2.7/httplib.py", line 1056, in request
self._send_request(method, url, body, headers)
File "/usr/lib64/python2.7/httplib.py", line 1090, in _send_request
self.endheaders(body)
File "/usr/lib64/python2.7/httplib.py", line 1052, in endheaders
self._send_output(message_body)
File "/usr/lib64/python2.7/httplib.py", line 894, in _send_output
self.send(message_body)
File "/usr/lib64/python2.7/httplib.py", line 866, in send
self.sock.sendall(data)
File "/usr/lib64/python2.7/ssl.py", line 744, in sendall
v = self.send(data[count:])
TypeError: unhashable type
Что я здесь делаю? файл json действительный. Пожалуйста помоги. Заранее спасибо