devopshq / tfs

Microsoft TFS API Python client
https://devopshq.github.io/tfs/
MIT License
110 stars 28 forks source link

Error when updating WIT field #30

Open myksaquino opened 6 years ago

myksaquino commented 6 years ago

I am able to get details of a wit field using print(workitem['state'] ) but i am getting error when updating it..

I am getting below error when updating wit field:

Traceback (most recent call last): File "C:\Python35-32\lib\site-packages\dohq_tfs-1.0.dev0-py3.5.egg\tfs\connection.py", line 224, in __send_request File "C:\Python35-32\lib\site-packages\requests-2.18.4-py3.5.egg\requests\models.py", line 892, in json return complexjson.loads(self.text, **kwargs) File "C:\Python35-32\lib\json__init__.py", line 319, in loads return _default_decoder.decode(s) File "C:\Python35-32\lib\json\decoder.py", line 339, in decode obj, end = self.raw_decode(s, idx=_w(s, 0).end()) File "C:\Python35-32\lib\json\decoder.py", line 357, in raw_decode raise JSONDecodeError("Expecting value", s, err.value) from None json.decoder.JSONDecodeError: Expecting value: line 1 column 1 (char 0)

During handling of the above exception, another exception occurred:

Traceback (most recent call last): File "D:/Release/PythonProjects/TFSAPI.py", line 33, in workitem['state'] = 'Pending Review' File "C:\Python35-32\lib\site-packages\dohq_tfs-1.0.dev0-py3.5.egg\tfs\resources.py", line 89, in setitem File "C:\Python35-32\lib\site-packages\dohq_tfs-1.0.dev0-py3.5.egg\tfs\connection.py", line 107, in update_workitem File "C:\Python35-32\lib\site-packages\dohq_tfs-1.0.dev0-py3.5.egg\tfs\connection.py", line 189, in send_patch File "C:\Python35-32\lib\site-packages\dohq_tfs-1.0.dev0-py3.5.egg\tfs\connection.py", line 231, in __send_request tfs.connection.TFSClientError: Response is not json: Invalid Http Request Header

myksaquino commented 6 years ago

tried debugging and it seems the first try to send request is failing. Then sending it again, i am getting a successful response.

so i add a tweak on my code to send the request twice...

this function update fields twice

def update_data(workitem, work_item_value, data): try: workitem[work_item_value] = data except BaseException: pass workitem[work_item_value] = data