Forums

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

Error when calling Jira API to create an issue

Jason Liu
Contributor
July 1, 2022

Response is: {"errorMessages":[],"errors":{"Affects Version/s":"Field 'Affects Version/s' cannot be set. It is not on the appropriate screen, or unknown."}}

Does anyone who know about this? The value exists in the project.

2 answers

1 vote
Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 1, 2022

This is what it says it is - if you go into the UI and try "create issue", you will find that the affects version field is not asked for.

Either remove it from your REST call, or add it to the create screen so it can be filled in.

(There is one other way to get this message - it might be that the user account you are using to make the call does not have permission to see or create issues in thsy project.

Jason Liu
Contributor
July 3, 2022

Hi NIc, Yes, I understood. What I meant is that we already have Affects Version/s field on the create screen and we tried to create it in Jira and it succeeded. But when we call API, it always showed the error message. I also checked the user's access and she has the project create issue permission. So there's no other possible reason?

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 4, 2022

Can you log in as the user using the REST call, and try to create an issue of the same type that your REST call? 

Are you offered the affects version field then?  Also, if so, is it the first field on the screen (other than summary, issue type and project)?

(Basically, we need to check all the things it could be by trying it in the UI - are you sure you're using the same user for the REST call, same issue type so it should have the same fields, etc)  

aliva dash July 5, 2022

the affected version has drop down list in the jira screen while creating a ticket. In the java script when i give + "\"Affects Version/s\":{\"name\":\"values\"}," it gives error as  Response is: {"errorMessages":[],"errors":{"Affects Version/s":"Field 'Affects Version/s' cannot be set. It is not on the appropriate screen, or unknown."}}

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2022

Is it an issue of the same type as the one you tested in the UI?  Same project?  Same user?

Jason Liu
Contributor
July 6, 2022

Hi Nic,

You just mentioned the first field on the screen other than summary. So if it's not, will it have influence? I think others we are all OK.

aliva dash July 6, 2022

yes, used same user same ui and same project.

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2022

Can you give us the full text of the command you are running (obscure the URL you are calling and the content of fields you don't want us to see).

And a screenshot of the create issue screen might be helpful.

aliva dash July 6, 2022

i am using the below command:

createData = "{\"fields\":{" + "\"project\":{\"key\":\"" + pty.getProperty("DQDefaultProjectKey") + "\"},"
+ "\"issuetype\":{\"name\":\"Production Bug\"},"
+ "\"Affects Version/s\":{\"name\":\"\"},"
+ "\"summary\":\"Issue with: " + element1 + " for table: " + table + " in domain: " + domain1 + ""
+ "\"," + "\"description\":\""
+ "DataElement: " + rs.getString("BIZ_FIELD_NAME")
+ " failed DQ check for rule: " + rs.getString("RULE_NAME") + ". "
+ "Current DQ score is: " + rs.getString("DQ_SCORE") + ". The bad record file is available at: " + pty.getProperty("DQExceptionFilePath") + exceptionFilePath
+ "\","
+ "\"priority\":{\"name\":\"" + getPriority(rs.getString("PRIORITY")) + "\"},"
+ "\"reporter\":{\"name\":\""
+ pty.getProperty("DQTaskDefaultReporter") + "\"},"
+ "\"assignee\":{\"name\":\""
// + getTaskAssignee(rs.getString("STEWARD"), pty).replace(pty.getProperty("LenovoDomain"), "") + "\"}";
+ pty.getProperty("DQTaskDefaultReporter") + "\"}";

createData = createData + "}}";
System.out.format("%s: createData for Task is: %s\n", thisClass, createData);
logger.debug("createData for Task is: " + createData);

Nic Brough -Adaptavist-
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 6, 2022

That's not a command, it's only the content you're sending, but it is the problem.

I should have spotted this sooner, I'm sorry.  You did give us the information I needed to spot the problem earlier, but I missed it.

The error is correct - there is no "Affects version/s" field on your screen.  Because that's not the real name of the field.  The field is a system one, which is shown with one name, but in the background has a different name.

Try sending "versions" instead of "Affects Version/s"

Like aliva dash likes this
aliva dash July 6, 2022

super. Thanks it worked .

i made the change to + "\"versions\":[{\"name\":\"value\"}]

 

and it worked. Many thanks

0 votes
Pramodh M
Community Champion
July 1, 2022

Hi @Jason Liu 

The respective field should be on the screen to add the value via API. Please check

Thanks,
Pramodh

Jason Liu
Contributor
July 1, 2022

Hi Pramodh, What if they are the same? Is there any other possible reason?

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
SERVER
VERSION
8.5.2
TAGS
AUG Leaders

Atlassian Community Events