Git Product home page Git Product logo

Comments (5)

SAnCherepan avatar SAnCherepan commented on August 15, 2024 1

@dgtlrift, there is no "clean" way (yet) to do it with our library.

However, the connection.create_workitem method has the relations_raw parameter that you could use to add links right away.

The code for using relations_raw should look like this:

existing_wi = TFSAPI.get_workitem(123)

parent_link_raw = 
	[
		{
			"rel": "System.LinkTypes.Hierarchy-Reverse", # existing WI will be a parent, new WI will be a child
			"url": existing_wi.url
			"attributes": {
				"isLocked": false
			}
		},
	]

new_wi = TFSAPI.create_workitem("Task", parent_link_raw)

This is a temporary solution as we are yet to implement adding "normal" links, attachments and now raw JSON, but it should work.

from tfs.

SAnCherepan avatar SAnCherepan commented on August 15, 2024 1

@ihar512, sorry for the delay.

Troubleshooting steps would be the following:

  1. Ensure that creating a regular (non-linked) item works:
    new_wi = client.create_workitem("Task")
  2. Ensure that linking that item to the parent item works:
    new_wi.add_relations_raw(parent_link_raw)

Let me know if you need any extra info on any of these steps.
When both creation and linking work, the whole thing should also work.

from tfs.

ihar512 avatar ihar512 commented on August 15, 2024

@SAnCherepan I actually tried what you suggested and it doesn't seems to work. Here is the error I am getting, could you give me some suggestions? Thanks.

Traceback (most recent call last):
File "tfsfsa.py", line 40, in
new_wi = client.create_workitem("Task", fields=None, relations_raw=parent_link_raw)
File "C:\Python36\tfs\connection.py", line 197, in create_workitem
api_version)
File "C:\Python36\tfs\connection.py", line 170, in __create_workitem
raw = self.rest_client.send_post(uri=uri, data=data, headers=headers, project=True, payload=params)
File "C:\Python36\tfs\connection.py", line 343, in send_post
return self.__send_request('POST', uri, data, headers, payload=payload, project=project)
File "C:\Python36\tfs\connection.py", line 386, in __send_request
response.status_code, result['error'] if 'error' in result else response.reason))
tfs.connection.TFSClientError: TFS API returned HTTP 400 (Bad Request)

from tfs.

ihar512 avatar ihar512 commented on August 15, 2024

Also here is my code,

existing_wi = client.get_workitem(9133)
parent_link_raw = [
{
"rel": "System.LinkTypes.Hierarchy-Reverse", # existing WI will be a parent, new WI will be a child
"url": existing_wi.url,
"attributes": {
"isLocked":False
}
},
]
new_wi = client.create_workitem("Task", relations_raw=parent_link_raw)

from tfs.

ihar512 avatar ihar512 commented on August 15, 2024

@SAnCherepan, I was able to resolve this issue with your suggestion. Thank you!

from tfs.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.