Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

How to add existing issue to sprint? I am getting error "Number value expected as the Sprint id."

I want to add existing Jira issue to sprint. I got the sprint from RapidView

// get the current sprint
GreenHopperClient gh = new GreenHopperClient(jira);
/* Retrieve all Rapid Boards */
List<RapidView> allRapidBoards = gh.getRapidViews();
/* Retrieve a specific Rapid Board by ID */
RapidView board = gh.getRapidView(2915);
/* Print the name of all current and past sprints */
List<Sprint> sprints = board.getSprints();
// get the last sprint in the list
Sprint s = sprints.get(sprints.size()-1);

List<String> lstSprints = new ArrayList<String>();

Issue iss = jira.getIssue("NGMTS-15434");
iss.update().field("customfield_10102", lstSprints).execute();

This code gives me following error.

Failed to update issue NGMTS-15434
400 400: {"errorMessages":["Number value expected as the Sprint id."],"errors":{}}

I tried sending the list of Integers which didn't work. What can be the problem here? Please help me in the understanding this problem.


3 answers

1 accepted

0 votes
Answer accepted

I couldn't solve the above mention problem. So I tried alternate approach of using REST API instead of JiraClient and it worked. Following Java code successfully adds the issue in the given sprint.

public static void addIssueToSprint(String strIssueKey, int nSprintNo)
try {
// set the URL and connection
URL urlForGetRequest = new URL("https://<hostname>/rest/api/2/issue/" + strIssueKey);
HttpURLConnection connection = (HttpURLConnection) urlForGetRequest.openConnection();
// set the method as PUT as the request is to update the Issue
connection.setRequestProperty("Content-Type", "application/json");
connection.setRequestProperty("Accept", "application/json");
connection.setInstanceFollowRedirects( false );
// set the authorization data
String auth = "<username>:<password>";
byte[] encodedAuth = Base64.encodeBase64(auth.getBytes(StandardCharsets.UTF_8));
String authHeaderValue = "Basic " + new String(encodedAuth);
connection.setRequestProperty("Authorization", authHeaderValue);

// set the payload with sprint number
String jsonInputString = "{\r\n" +
"\"fields\":{\r\n" +
"\"customfield_10102\":"+ nSprintNo +"\r\n" +
"}\r\n" +

OutputStreamWriter osw = new OutputStreamWriter(connection.getOutputStream());
if(connection.getResponseCode() >= 400)
System.err.println("Couldn't add the issue to sprint: " + connection.getResponseCode());
System.out.println("Issue added to the sprint: " + nSprintNo);
} catch (MalformedURLException e) {
// TODO Auto-generated catch block
System.err.println("Couldn't add the issue to sprint: " + e.getMessage());
} catch (IOException e) {
// TODO Auto-generated catch block
System.err.println("Couldn't add the issue to sprint: " + e.getMessage());

0 votes
Sherry Goyal Atlassian Team Sep 07, 2020

@Arvind Jagtap 


From a quick glance, seems like 

            List<String> lstSprints = new ArrayList<String>(); 

should be of "long" type. Maybe give it a shot and try solving your problem.



Since ArrayList doesn't hold primitive data types, I tried following code to create a list

Long lSprintNo = new Long(s.getId());
List<Long> lstSprints = new ArrayList<Long>();
iss.update().field("customfield_10102", lstSprints).execute();

But it is giving the same error as mentioned below.

Failed to update issue NGMTS-15434
400 400: {"errorMessages":["Number value expected as the Sprint id."],"errors":{}}

Sherry Goyal Atlassian Team Sep 07, 2020

I would suggest to do try bunch of things:

1. Try without putting into list. Directly:

iss.update().field("customfield_10102", lSprintNo).execute();

2. Try setting sprint value to sprint fields:

iss.update().field("Sprint", sprint.getName()).execute();

3. Similar thing was achieved here:

See if this helps you in anyway


else wait for the subject matter expert to give some advice on this. 


Thanks Sherry for looking into it and suggesting various options.

I have tried initially assigning the sprint number directly instead of list and I got error "Field expects an Iterable value". Since then I am trying to set the list.

That error is also applicable to the second option you suggested. I also read at some other place that sprint number should be specified instead of name as there can be multiple sprints with same name.

I saw the script provided in the link which has completely different object model. I couldn't find these objects (GreenHopperBean, SprintManager, etc.) in JiraClient library. So I couldn't use this script. I am using Java which is different than this scripting language.

So not able to proceed further and will wait for response from subject matter expert. Anyway thanks for your quick responses and the help.

0 votes
Curt Holley Community Leader Sep 07, 2020

What version of Jira are you using? and are you using Automation for Jira to do the automation?

I am using Jira v8.5.3. While selecting the category, I thought Jira Automation is a category and didn't know that it is a separate product. I am writing a program to automate Jira user interaction using the JiraClient library.

Suggest an answer

Log in or Sign up to answer
Community showcase
Published in Jira Automation

New to Jira Automation - goodbye Cron (sort of), hello new project created trigger, new additions to

Hey Everyone! Simeon from the Automation team here. I'm delighted to share some new features and improvements that we are shipping to Jira automation (Cloud only). Firstly, @Sam Harding&nbsp...

2,873 views 10 23
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you