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

Jira REST client SDK: Can't set assignee or fixVersion

J June 2, 2014

tl;dr: halp!!!!

I'm using jira-rest-java-client-core version 2.0.0-m26.

The following code:

JiraRestClient restClient = FACTORY.createWithBasicHttpAuthentication(jiraServerUri, USERNAME, PASSWORD);

         Set<String> affectedVersionNames = new HashSet<String>();

         affectedVersionNames.add("Mavericks");

         ...

         issueInputBuilder.setAssigneeName("MrJobs");

         issueInputBuilder.setFixVersionsNames(affectedVersionNames);

Returns:
Exception in thread "main" RestClientException{statusCode=Optional.of(400), errorCollections=[ErrorCollection{status=400, errors={assignee=Field 'assignee' cannot be set. It is not on the appropriate screen, or unknown., fixVersions=Field 'fixVersions' cannot be set. It is not on the appropriate screen, or unknown.}, errorMessages=[]}]}

I have read the JavaDoc but it doesn't deeply explain the issueInputBuilder.setAssigneeName() nor setFixVersionNames() methods. One issue with the straight up API from over a year ago indicates that the error is due to an authentication issue:
The accepted answer says to "check if 'reporter' field is on the 'create' screen for not logged in users or check if the user you are using has necessary permissions." I am certain I cannot create new users nor fix versions but I am not sure if I can create components because I don't appear to have access to the administrator settings for the "create screen", unless he's referring to the dialog that pops up when you click the Create Issue button.
However, I can use the issueInputBuilder.setComponentsNames() method if an only if I pick an existing component. Otherwise I get components=Component name 'Gargalablah' is not valid. Since I can create neither components nor users & fixVersions, this leads me to believe that this may not be an authentication or permissions issue. But it's possible that using the setComponentsNames() method simply does not allow users to create new components even if they have permissions to.
  1. The question at https://answers.atlassian.com/questions/48192/jira-rest-5-0-create-issue-errordescribes a solution whereby "The HTTP Basic Session Cookie just need to be preemptive." How would I create IssueInputBuilder to use a pre-emptive HTTP Basic Session Cookie in Java?
  2. If my cookie is set properly and this still doesn't work, e.g. if it's both an authentication and permissions issue, would giving my account the ability to create new users and fixVersions alleviate the problem?
  3. Could the error message mean anything else?

2 answers

1 accepted

Comments for this post are closed

Community moderators have prevented the ability to post new answers.

Post a new question

0 votes
Answer accepted
J June 13, 2014

It turns out that 3) is the culprit as the error messages means something different: "Field 'assignee' cannot be set. It is not on the appropriate screen, or unknown." doesn't mean that the field cannot be set within the Jira UI. It means that it can't be set from the issue creation dialog box.

The fix was to ask my company's Jira administrator to allow all users to be able to set assignees and fixVersions when they create new issues.

A hack that would have worked would have been to first submit the issues without assignees or fixVersions, fetch them again, and set set the assignee and fixVersions.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 13, 2014

Er, no. The error message is correct.

The field assignee was not on screen. Because the user you are using does not have assign issue permissions, so Jira removes it from the edit screens.

The underlying reason is wrong, but the error message is correct.

J June 13, 2014

"It is not on the appropriate screen, or unknown." is correct only if the user-developer mentally maps the API's functionality to the UI's functionality. If that abstraction is made, the underlying reasoning is actually correct because the fields weren't on the "appropriate screen", e.g. the Create Issue dialog box.

Given how many forum topics have been created about the same error message, I think many aren't making that mental abstraction.

Maybe an improvement the Altassian team could make would be to make this error message clearer to end users.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 13, 2014

No, it's still correct - think of it this way - was the field on screen when you used the UI as that user?

The mental-map isn't necessary, just a look at the screen. There are a number of these cases where permissions can hide a field from use, and it's not really feasible to give the underlying cause because there's a maze of permissions that could be causing it to be off-screen. The error message "it's not on screen or not available" is correct, even if it's not the underlying cause

J June 13, 2014

It doesn't need to say the root cause. It just needs to say where the problem is if it's going to make analogies with the UI. Since I am creating an issue, the "appropriate screen" is always the Create Issue dialog.

Field 'assignee' cannot be set. It is not on the Create Issue screen, or unknown.

I didn't even know that "appropriate screen" had anything to do with the UI until I came here so checking the Create Issue dialog didn't even occur to me.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 13, 2014

Sorry, I should have said, I'm not strongly disagreeing with you - it's just that the error message here is accurate. I completely see that it's confusing because it doesn't directly give you the root cause, be nice if it did.

There are quite a few more examples where Jira will give you an accurate but not-root-cause error message because there could be any number of different causes for the same behaviour.

J June 13, 2014

It just needs to say where the problem is, not what's causing it. I didn't interpret "appropriate screen" to mean a UI object so seeing if the fields could be set in the Create Issue dialog didn't even occur to me. But it would have if I'd made the mental abstraction.

I may have if the error message said which UI object is the "appropriate screen". Since I am creating an issue, the "appropriate screen" is always the Create Issue dialog.

Field 'assignee' cannot be set. It is not on the Create Issue screen, or unknown.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 13, 2014

The problem there is that it doesn't necessarily know that you're on the create screen. Again, that's a quirk of the internals, but yes, that would definitely be a better message.

0 votes
Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 2, 2014

Start with a basic test - can you log into Jira as the user you are running the REST client as, and create an issue, setting the fixversion and assignee? If the web-ui can't do it, then REST won't.

The error message you're getting really does mean what it says in most cases - the system isn't configured to allow you to do what you're trying to do in REST.

Ma Hao June 2, 2014

From the error:

It is not on the appropriate screen, or unknown.

I suppose there are some problems with the Issue Screen.

Maybe assignee and fixversion are not contained in current screen.


J June 2, 2014

I'm trying to set the fixVersion and assignee through the SDK (which connects to Jira OnDemand via the API), not through the UI. I don't even know what a "screen" is because the message is so cryptic. Could you please elaborate on what "contained in the current screen" means in reference to the SDK?

J June 2, 2014

I already tried that before I posted. I can create issues and set fixVersions and assignees, but I can't create new fixVersions and users. I shouldn't need the ability to create and delete new fixVersions to be able to _set_ an issue's fixVersion.

Ma Hao June 2, 2014

So, you mean that you do not know about what is JIRA Issue Screen?

You know, before you set any field on JIRA issue or create jira issue, you need to make sure all field you needed are included into your issue screen.

Nic Brough -Adaptavist-
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
June 2, 2014

Creating a version is different from setting a version and done in a completely different place.

The error message is clear - you have not got the fields you need on the "create screen" for some reason. You say you're able to set them when using the gui, but are you 100% sure you are using the same user in REST? As different users can have different rights.

J June 13, 2014

It might be clear to the people who developed the SDK but it's unclear enough for people who use the SDK that there's many topics on nearly identical error messages.

TAGS
AUG Leaders

Atlassian Community Events