How to connect preconditions with tests in Jira X-Ray?

Hey everyone, I’m trying to move our test cases from TestRail to Jira X-Ray. I’m using the JIRA API to do this. I can make the tests and preconditions okay, but I can’t figure out how to connect them.

When I look at the XML for both types of issues, I don’t see any linked issues for the preconditions. I know X-Ray has an API that might help, but it looks like it’s only for the server version. We’re using the cloud version.

Has anyone here tried to add preconditions using the JIRA API? Or does anyone know how X-Ray links these things together? I’m kinda stuck and could use some help. Thanks!

hey nate, i’ve done this before. the trick is using jira’s issue linking api. create ur test n precondition issues first, then use ‘/rest/api/2/issueLink’ endpoint to connect em. use ‘Test Set’ as link type. it’s not perfect but works for cloud. you’ll need to play around a bit to get it right. good luck!

As someone who’s worked extensively with Jira X-Ray, I can share some insights on connecting preconditions to tests. While the JIRA API doesn’t directly expose X-Ray’s linking mechanism, there’s a workaround you can use.

First, create your test and precondition issues separately via the JIRA API. Then, use the “/rest/api/2/issueLink” endpoint to create a link between them. The trick is to use the correct link type - for X-Ray, it’s usually “Test Set”. Your JSON payload should look something like this:

{
“type”: {“name”: “Test Set”},
“inwardIssue”: {“key”: “TEST-123”},
“outwardIssue”: {“key”: “PRECOND-456”}
}

Replace the keys with your actual issue keys. This method has worked well for me in the past when migrating from other tools. It’s not as straightforward as using X-Ray’s API, but it gets the job done for cloud instances. Just be prepared for some trial and error to get the link types right.

Having migrated test cases to Jira X-Ray myself, I can offer some practical advice. While the JIRA API doesn’t directly support X-Ray’s precondition linking, there’s a workaround. After creating your test and precondition issues via the API, use the ‘/rest/api/2/issueLink’ endpoint to establish the connection. The key is using the correct link type, typically ‘Test Set’ for X-Ray. Construct a JSON payload with the issue keys and link type, then send a POST request to create the link. This method, though not as straightforward as X-Ray’s server API, is effective for cloud instances. Be prepared for some experimentation to get the link types right. It’s a bit cumbersome, but it gets the job done when migrating from other tools like TestRail.