Forums

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

trying to create an issue, but the error says that a field is required, event though it is not

Noa Shay February 20, 2022

hello, 

i'm trying to create an issue via jira's api, and this error returns:

{

"errorMessages": [

"Field Affects versions is required."

],

"errors": {}

}

but when I request from the jira api all the fields of that issue type, it says that the field 'Affects versions' is not required: (required: false)

"versions": {

"required": false,

"schema": {

"type": "array",

"items": "version",

"system": "versions"

},

"name": "Affects versions",

"key": "versions",

"hasDefaultValue": false,

"operations": [

"set",

"add",

"remove"

],

also, when i'm trying to create the same issue in the jira ui, i'm getting the same error. (and you can see that this field is not required, like the field 'components'

Screen Shot 2022-02-20 at 13.47.08.png

how am i supposed to know that this field is required when i'm creating an issue via jiras api, if even the api says that its not?

 

thanks!

2 answers

1 accepted

1 vote
Answer accepted
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.
February 20, 2022

Welcome to the Atlassian Community!

It looks like you are using a validator to make the field required, rather than doing it in the field configuration (if you did it in there, the * that indicates a field is mandatory would appear on the create screen)

You'll need to adjust your REST call such that it fills in a valid version, or remove the validator from the create transition.

Noa Shay February 20, 2022

hey, first of all thank you for your comment!

I wanted to ask - what do you mean by 'adjust your REST call such that it fills in a valid version'?

 

i just want to make an api call to get all the issue types and their fields:

https://your-domain.atlassian.net/rest/api/latest/issue/createmeta?expand=projects.issuetypes.fields


 and that it will say on the 'Affects versions' field that it is a required field.

how can i do that?

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.
February 20, 2022

I mean that if you want to create an issue, you will need your REST call to send an affects version.

Noa Shay February 20, 2022

oh ok.

But the problem is i'm developing a feature that allows users to create issues in jira, and in order to do that I need their issues metadata, where all the required fields are returning. 

If i get the 'Affects versions' field in the request and it will say that it is not required, I will not have a way to know I need to send this field when creating an issue.

That's why I asked if there is a way to retrieve all of the required fields in the createmeta request

thank you 

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.
February 20, 2022

I am sorry, I was focussing more on the error, and your comment just made me realise I'm not talking about your actual question!  I should have seen that earlier.

The problem here is how your admins have made the field mandatory.  It's not their fault, nor what you are doing, it's the way Jira works.

Jira can tell you when a field is mandatory because the field configuration says the field is, but it can not understand all the things you might be doing in a validator.   The validator could be doing almost anything (especially when you've got an automation or scripting app).  

Jira can see validators, but it can not understand them for us.  You and I can easily read a bit of (validator) code and say "oh, well that makes field X mandatory", but Turing machines don't understand it.

TLDR: There is no way Jira can tell you what the impact of your validators are over the REST API.  Until you try something that fails validation.

Noa Shay February 23, 2022

thank you for your answer!

Vigneshwaran R
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 16, 2024

@Noa Shay I am facing the same issue and i am not able to understand his previous reply and solution. can you explain how you solved it ?

 

0 votes
Pramodh M
Community Champion
February 20, 2022

Hi @Noa Shay 

When you are creating an Issue in Jira UI, I believe you are entering the required fields.

Now what you need to do is Perform a GET API on any of the Issues and take the field ID

Example below

curl --request GET \ 
--url 'https://your-domain.atlassian.net/rest/api/3/issue/{issueIdOrKey}' \
--user 'email@example.com:<api_token>' \
--header 'Accept: application/json'

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-issueidorkey-get

Now format the API Data to create Issue using POST API

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post

With additional field details, it would be something like

{
"fields": {
"customfield_10082": {
"value": "Affects Version Field Value"
}
}
}

Let me know if you have any queries

Reach out to Jira Admin or your peers if you are facing problems in creating Issue

Thanks,
Pramodh

Suggest an answer

Log in or Sign up to answer