How do i link existing Epic issues with a csv file
Asked by Kenert K?nnapuu:

I have existing Jira Epic issues. 211 to be exact. I have defined the relationships between them in a google sheets document that i can export as a csv. I have two columns. Column A contains the "parent" and column B contains the "child" values are issueID-is.

![csv Picture.png](https://community.atlassian.com/t5/image/serverpage/image-id/344063i61923B4BDE447F34/image-size/large?v=v2&px=999 "csv Picture.png")

Can and how i can use this CSV file to link all of these issues to each other. There are over 700 links that need to be made and I tried doing this in batches of 240. Import csv also requires a summary, i placed a dummy value in there since I am not creating any new issues. Just trying to link existing Epic-s to each other.

![jiratest1.png](https://community.atlassian.com/t5/image/serverpage/image-id/344064iB4B5BE1669467ABC/image-size/large?v=v2&px=999 "jiratest1.png")

When I try to do this, it gives me warnings. That some issues were not found. But i checked and all the issueID-s actually exist. So is there antoher/better way to go about this or is this even possible?

![MapValues.png](https://community.atlassian.com/t5/image/serverpage/image-id/344065iCD6BC470CFE10A90/image-size/large?v=v2&px=999 "MapValues.png")

If i look at the detailided validation........ it tries to create new issues. But i already have all these issues. Can they be linked togheter?


Answers:
author: Marc - Devoteam
body: Hi [@Kenert K?nnapuu](/t5/user/viewprofilepage/user-id/5577763)

Do you want to achieve a parent - child relation or an issue link relation?

Issue Id is for parent child relation and blocks is for an issue link relation.

For parent child relation, you need 3 columns in your csv, issue id, issue type and parent.

Also see the KB article on CSV import; [import-data-from-a-csv-file](https://support.atlassian.com/jira-cloud-administration/docs/import-data-from-a-csv-file/)

Issue linking is done different, see; [how-to-import-issue-links-from-a-csv-file-in-jira](https://confluence.atlassian.com/jirakb/how-to-import-issue-links-from-a-csv-file-in-jira-740262715.html) (the article says server/dc only, but the same applies for Cloud).

comments: author: Kenert K?nnapuu
body: I want to achive issue link relation. Blocks


author: Marc - Devoteam
body: Hi [@Kenert K?nnapuu](/t5/user/viewprofilepage/user-id/5577763)

Use the kb article: [how-to-import-issue-links-from-a-csv-file-in-jira](https://confluence.atlassian.com/jirakb/how-to-import-issue-links-from-a-csv-file-in-jira-740262715.html)


author: Jim Knepley - ReleaseTEAM
body: I think this is the right answer, but if it doesn't work because of the summary field requirement you can always roll your own with the [issue link API](https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-links/#api-rest-api-2-issuelink-post).


author: Kenert K?nnapuu
body: If go with the "how to import isse links from a csv file in jira" it creates new issues. My problem is that the issues already exist. And existing issues need to be linked


author: Jim Knepley - ReleaseTEAM
body: OK. This is quick-and-dirty, but this Python will read from a CSV file and link the issues in the abovementioned columns. You'll need to make changes to your own domain name and authentication.

```
import csv
import json

import requests

jira_api = requests.Session()
jira_api.headers.update({"Accept": "application/json", "Content-Type": "application/json"})
jira_api.auth = ("email", "api_token")
atlassian_domain = "your-domain.atlassian.net"

def link_issue(inward, outward, link_type="Blocks"):
    response = jira_api.request(
        "POST",
        f"https://{atlassian_domain}/rest/api/2/issueLink",
        data=json.dumps(
            {
                "inwardIssue": {"key": inward},
                "outwardIssue": {"key": outward},
                "type": {"name": link_type},
            }
        )
    )
    response.raise_for_status()

with open("links.csv") as links_csv:
    reader = csv.DictReader(links_csv)
    for line in reader:
        link_issue(line["IssueId"], line["Blocks"])
        print(f"{line["IssueId"]} > {line["Blocks"]}")
```

```

```


author: Kenert K?nnapuu
body: Thank you for the script


Tags: cloud

jira-cloud