Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

JSON import of sprints doesn't work

Randall Hink July 21, 2023

I'm trying to import issues with sprint information, per the documentation here.

 

This is just the example from the above link - Jira's own documentation. There's a typo in the original (unclosed quotation) which I've fixed here. If I run this through the json importer:

 

{
"projects": [
{
"name": "Project",
"key": "KEY",
"issues": [
{
"externalId": "51",
"priority" : "High",
"description" : "Test JSON import",
"status" : "TO DO",
"reporter" : "abcde-12345-fedcba",
"issueType" : "Bug",
"summary" : "Test JSON import",
"customFieldValues": [
{
"fieldName": "Sprint",
"fieldType": "com.pyxis.greenhopper.jira:gh-sprint",
"value": [
{
"rapidViewId": 30,
"state": CLOSED",
"startDate": "2018-01-01",
"endDate": "2018-01-01",
"completeDate": "2018-01-01",
"name": "New Sprint"
}
]
}
]
}
]
}
]
}

 

I get the following error:

 

2023-07-21 21:42:17,718 WARN - Cannot add value [ [{rapidViewId=30, state=CLOSED, startDate=2018-01-01, endDate=2018-01-01, completeDate=2018-01-01, name=New Sprint}] ] to CustomField Sprint in Issue with summary 'Test JSON import'. Probably value was in incorrect format

 

And of course none of my own data works, either.

 

Any ideas???

1 answer

1 accepted

1 vote
Answer accepted
Kseniia Trushnikova
Community Champion
July 21, 2023

Hi @Randall Hink,

Do you have the board with rapidViewId = 30? To check this, open the URL: https://YOUR_JIRA/secure/RapidBoard.jspa?rapidView=30

It's necessary to use the ID of the existing board.

Randall Hink July 21, 2023

Thank you for the response!

At your recommendation, I changed the rapidViewId to match a board that does exist - and I still get the same error, unfortunately.

Kseniia Trushnikova
Community Champion
July 21, 2023

@Randall Hink, sorry for misleading. I've just tried to create active and closed sprints and failed. But this works for creating future sprints (even there's no need to change rapidViewId):

{
"projects": [
{
"name": "Project",
"key": "KEY",
"issues": [
{
"externalId": "51",
"priority" : "High",
"description" : "Test JSON import",
"status" : "TO DO",
"reporter" : "abcde-12345-fedcba",
"issueType" : "Bug",
"summary" : "Test JSON import",
"customFieldValues": [
{
"fieldName" : "Sprint",
"fieldType" : "com.pyxis.greenhopper.jira:gh-sprint",
"searcherType" : "com.pyxis.greenhopper.jira:gh-sprint-searcher",
"value" : [ {
"id" : 10,
"rapidViewId" : 30,
"state" : "FUTURE",
"name" : "TEST SPRINT",
"startDate" : "2023-01-01",
"endDate" : "2023-01-01",
"sequence" : 10,
"autoStartStop" : false,
"synced" : false,
"future" : true,
"closed" : false,
"active" : false
} ]
} ]
} ]
} ]
}

 I don't get what values should I add to create closed sprints, because adding "completeDate" and "activatedDate" doesn't work.

Like Marc - Devoteam likes this
Randall Hink July 21, 2023

No problem, I sincerely appreciate the help.

I definitely need to be able to create closed sprints; I'm migrating current and historical data from another system.

I think I'm just going to work around it using the REST API to script sprint creation instead:

https://developer.atlassian.com/cloud/jira/software/rest/api-group-sprint/#api-rest-agile-1-0-sprint-post

Randall Hink July 24, 2023

So it's a little bit convoluted, and maybe there's an easier way to do it, but here's what ended up working for me:

  1. Create my sprints through some other process. Because in my case there weren't a ton of sprints, I did it manually, but via the Jira REST API would work as well.
  2. Pull down sprints from Jira via REST API.
  3. Search the Jira sprints for a date match with my external system sprints. Grab "id" field from the matching sprint.
  4. Populate the "Sprint" custom field in the Jira upload JSON with only the id # (I have no idea where this is documented, but it works to associate the issue and sprint)

What I end up uploading into Jira looks something like this:

{
"projects": [
{
"name": "Project",
"key": "KEY",
"issues": [
{
"externalId": "51",
"priority" : "High",
"description" : "Test JSON import",
"status" : "TO DO",
"reporter" : "abcde-12345-fedcba",
"issueType" : "Bug",
"summary" : "Test JSON import",
"customFieldValues": [
{
"fieldName": "Sprint",
"fieldType": "com.pyxis.greenhopper.jira:gh-sprint",
"value": 42
}
]
}
]
}
]
}

 

Note the "42" value in the custom field value comes from the JSON retrieved from the Jira REST API board/{boardId}/sprint endpoint, which would look something like this:

 

{
  "maxResults": 2,
  "startAt": 1,
  "total": 5,
  "isLast": false,
  "values": [
    {
      "id": 42,
      "self": "https://your-domain.atlassian.net/rest/agile/1.0/sprint/23",
      "state": "closed",
      "name": "sprint 1",
      "startDate": "2015-04-11T15:22:00.000+10:00",
      "endDate": "2015-04-20T01:22:00.000+10:00",
      "completeDate": "2015-04-20T11:04:00.000+10:00",
      "originBoardId": 5,
      "goal": "sprint 1 goal"
    }
  ]
}

 

If there's a way to actually create the sprints and associate them via JSON import, I haven't figured it out.

Like Kseniia Trushnikova likes this

Suggest an answer

Log in or Sign up to answer