Hi @NawazPasha,
Caterina here from Atlassian. I have a few comments about this for you.
Let me start by sharing what stood out to me:
- this is a Forge app which is adding a custom field
- the field is read-only
- the
/rest/api/3/issue/{issueIdOrKey}
fails with a 400
The ultimate goal is to attempt to update the custom field added from the Forge app via a REST API called by an external system.
If this is all correct, the short answer is that this is currently not possible. Let me share my research and sources with you.
The https://developer.atlassian.com/platform/forge/manifest-reference/modules/jira-custom-field/ page states that read-only fields are not editable via the Edit issue REST API
.
The way to update them is to use the POST /rest/api/2/app/field/value
(documented here: https://developer.atlassian.com/cloud/jira/platform/rest/v2/api-group-issue-custom-field-values--apps-/#api-rest-api-2-app-field-fieldIdOrKey-value-put page) this is only available in the context of Forge apps.
I’m checking with a few people to understand if there are more details that I can share and I’ll keep you posted.
When attempting to update such field using the REST API outside of a Forge app like:
--url 'https://<site>/rest/api/3/app/field/value' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"updates": [
{
"issueIds": [
11059
],
"value": "low",
"customField": "customfield_10073"
}
]
}'\
--basic --user '<email>:<token>'
The response I get is:
{"errorMessages":["Only apps can access this resource (impersonated requests are not allowed)."],"errors":{}}
Regarding your comments, I also want to add that:
- the most common reason for the field not being returned in the
rest/api/3/issue/{issueIdOrKey}/editmeta
or in the GET /rest/api/3/issue/{issueIdOrKey}?expand=editmeta
in the editmeta
section is that the field is not visible in the Edit screen. This guide has the steps to show them: Add a custom field to a screen | Atlassian Support
- the
400
usually indicates a problem with the way the API is called or one of the following condition is happening as documented on the PUT /rest/api/2/issue/{issueIdOrKey} end point under the 400
status code:
- the user does not have the necessary permission to edit one or more fields.
- the request includes one or more fields that are not found or are not associated with the issue’s edit screen.
- the request includes an invalid transition
Let me share the example I’ve been using today, these will result in an expected 400
status code:
--url 'https://<site>/rest/api/3/issue/{issueIdOrKey}' \
--header 'Accept: application/json' \
--header 'Content-Type: application/json' \
--data '{
"fields": {
"customfield_10073": "low"}
}'\
--basic --user '<email>:<token>'
This will return a {"errorMessages":[],"errors":{"customfield_10073":"Field does not support update 'customfield_10073'"}}
if the field is marked as read-only.
If the field is not read-only and visible on the edit screen, the update via REST API will succeed. If, instead, the field is not visible on the edit screen but still not read-only, the following error message is returned {"errorMessages":[],"errors":{"customfield_10073":"Field 'customfield_10073' cannot be set. It is not on the appropriate screen, or unknown."}}
.
I hope this clarifies a few things here. Please let me know if you have any follow up questions and I’ll let you know if I have any updates for you.
Thank you,
Caterina