devopshq / tfs

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

'TFSAPI' object has no attribute 'create_workitem' #83

Open zsmjluo opened 4 years ago

zsmjluo commented 4 years ago

https://devopshq.github.io/tfs/examples.html#create-or-copy-workitem

create_workitem return error

Tim55667757 commented 4 years ago

@zsmjluo Can you attach a complete trackback? What type of error? And how did you create a connection with TFS before that?

zsmjluo commented 4 years ago

@Tim55667757 reinstall doha-tfs:pip install dohq-tfs, create_workitem is ok. bug update workitem is wrong. Before reinstall doha-tfs,update workitem is ok.

workitem["State"] = "finish" File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tfs\resources.py", line 229, in setitem raw = self.tfs.update_workitem(self.id, update_data) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tfs\connection.py", line 224, in update_workitem payload=params) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tfs\connection.py", line 462, in send_patch return self.__send_request('PATCH', uri, data, headers, payload=payload, underProject=project) File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\tfs\connection.py", line 506, in __send_request response.raise_for_status() File "C:\Users\Administrator\AppData\Local\Programs\Python\Python37-32\lib\site-packages\requests\models.py", line 940, in raise_for_status raise HTTPError(http_error_msg, response=self) requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://localhost:8080/tfs/test/_apis/wit/workitems/18477?api-version=1.0&api-version=1.0

SAnCherepan commented 4 years ago

@zsmjluo, I was able to reproduce your error with update_workitem only with incorrect state (e.g. Completed instead of Complete.

Make sure you use the latest version (1.0.79 at the moment of writing) and specify correct state.

Let us know if it helps.