Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Unable to create work items #77

Open
harsheel87 opened this issue May 23, 2019 · 3 comments
Open

Unable to create work items #77

harsheel87 opened this issue May 23, 2019 · 3 comments
Labels
help wanted waiting for feedback Feedback from reporter is required. Issue will be closed otherwise.

Comments

@harsheel87
Copy link

I am using Azure DevOps Server 17.143.28912.1.

I am able to invoke get_workitem calls but create_workitem calls fail. Can someone point me what I may be doing wrong?

staging_client =  TFSAPI("https://staged-tfs.lan/tfs/", pat = 'pat')

fields = {'Title': 'test item: placeholder for new bug', 'Description': 'My description', 'AreaPath': 'Dev\\Data\\Server One', 'IterationPath': 'Dev\\Data Server', 'AssignedTo': 'TFSUnassigned <TSI\\_TFSUnassigned>'}

workitem = staging_client.create_workitem('DEFECT', fields=fields, api_version=5.0)

ERROR:

  ..
  File "E:\automateDashboard\proj1\venv\lib\site-packages\tfs\connection.py", line 309, in create_workitem
    api_version)
  File "E:\automateDashboard\proj1\venv\lib\site-packages\tfs\connection.py", line 282, in __create_workitem
    raw = self.rest_client.send_post(uri=uri, data=data, headers=headers, project=True, payload=params)
  File "E:\automateDashboard\proj1\venv\lib\site-packages\tfs\connection.py", line 456, in send_post
    return self.__send_request('POST', uri, data, headers, payload=payload, underProject=project)
  File "E:\automateDashboard\proj1\venv\lib\site-packages\tfs\connection.py", line 506, in __send_request
    response.raise_for_status()
  File "E:\automateDashboard\proj1\venv\lib\site-packages\requests\models.py", line 940, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 404 Client Error: Not Found for url: https://staged-tfs.lan/tfs/DefaultCollection/_apis/wit/workitems/$DEFECT?api-version=5.0
@harsheel87 harsheel87 changed the title Unable to create item in Unable to create work items May 23, 2019
@strahl
Copy link

strahl commented May 29, 2019

Hi @harsheel87, I stumbled upon the same issue. In my case I forgot the explicitly set the project id. And as get_workitem is more forgiving and runs without the project ID I did not notice this immediately. Here the "test" code that made me notice:

    client = TFSAPI(url, project = project, auth_type=HttpNegotiateAuth)    
    wi_fails = client.create_workitem('Bug', fields = fields)
    project_id = client.projects[0].id
    client_wtf = TFSAPI(url, project = f"{project}/{project_id}", auth_type=HttpNegotiateAuth)    
    wi_ok = client_wtf.create_workitem('Bug', fields = fields)

@allburov
Copy link
Member

allburov commented Jun 5, 2019

I have no installed Azure DevOps Server and don't can test this.
@harsheel87 Did the above advice about project_id help you?

@allburov allburov added the waiting for feedback Feedback from reporter is required. Issue will be closed otherwise. label Jun 5, 2019
@harsheel87
Copy link
Author

Thanks @strahl for the inputs. @allburov , sorry for the late reply as I had to leave on family medical leave but the project was shelved before we could try the suggestion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
help wanted waiting for feedback Feedback from reporter is required. Issue will be closed otherwise.
Development

No branches or pull requests

3 participants