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'
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!
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.
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?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I mean that if you want to create an issue, you will need your REST call to send an affects version.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@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 ?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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'
Now format the API Data to create Issue using POST API
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
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.