Using the REST API it is possible to link a defect to another entity.
In this article I want to show how to link an existing defect to a requirement using XML.
Identify required fields
According to the REST API documentation a link is described by the entity "defect-link".
First we need to identify required fields for the entity "defect-link". To do so we have to call the following URL e.g. using your browser.
Its important to query for fields?required=true. Else you will receive a list of all fields.
My example project returned the following information in XML format, which matches the standard.
So, regarding to the above XML response the minimum set of fields to create a new link between two defects or between a defect and e.g. a requirement is as follows.
POST a new link into the defect-links collection
Use the following URL to post a new defect-link.In order to create a new link between two entities, we have to POST an XML matching the Entity schema into the defect-link entity.
If you receive the HTTP Statuscode 201 ("Created") your request has been successfully processed and the link has been posted into the collection of defect-links.
If you receive the HTTP Statuscode 500 ("Internal Server Error") you will have to handle the returned exception message. For example if a link is already existing and you are trying to create it again, you will receive the following exception.