Screen errors when trying to add custom field and create an issue with that field

I’m developing an integration for importing issues into Jira using the v2 rest api and oauth2 authorization as described in https://developer.atlassian.com/cloud/jira/platform/oauth-2-authorization-code-grants-3lo-for-apps/.

My goal is to annotate imported issues with their id from the originating system (stackdriver) and to use those annotations to perform subsequent updates.

I can successfully create the custom field by sending POST to /rest/api/2/field with data {‘name’: ‘Stackdriver Incident ID’, ‘description’: ‘The ID of the stackdriver incident that created this issue.’, ‘type’: ‘com.atlassian.jira.plugin.system.customfieldtypes:readonlyfield’, ‘searcherKey’: ‘com.atlassian.jira.plugin.system.customfieldtypes:textsearcher’}.

I’m then attempting to create the issue by sending POST to rest/api/2/issue with data {‘fields’: {‘project’: {‘key’: ‘SM’}, ‘summary’: ‘test subject’, ‘description’: ‘test message’, ‘issuetype’: {‘name’: ‘Bug’}, ‘customfield_10033’: ‘12345’}}
but when I do this I’m getting a 400 with “Field ‘customfield_10033’ cannot be set. It is not on the appropriate screen, or unknown.”

After doing some searching around I found that this might be helped by adding this field to the default screen. I’m trying to do this by sending POST to rest/api/2/screens/addToDefault/customfield_10035 with no data, which returns ‘CREATED’, but after this I get the same issue creation error. I also tried manually adding the field to all available screens in the custom field management jira page with the same result.

I also tried adding &overrideScreenSecurity=true to the issue creation url, which returns {“errorMessages”:[“OAuth 2.0 is not enabled for this method.”]}.

Does anyone have any idea what could be causing the “Field ‘customfield_10033’ cannot be set. It is not on the appropriate screen, or unknown.” error? Is there some other field-screen relationship I need to establish? Am I not referring to the field correctly in the create issue request (although it seems to match the documentation afaict)? Am I totally misunderstanding how this is done? Any help would be really appreciated.

The field must be in-context and on screen of the operation.

Is the field you’re trying to set available on the createMeta endpoint? That should answer the question of whether or not you’re configured correctly: https://docs.atlassian.com/software/jira/docs/api/REST/8.6.0/#api/2/issue-getCreateIssueMetaFields

If the field isn’t on showing on the createMeta endpoint, you will not be able to set the field on the create operation. If the field is not showing on the createMeta endpoint, then you must ensure that the relevant Screen has the field and that the Field has an appropriate configuration scheme for this project/issuetype context.

Thanks for responding. The field doesn’t show up in createMeta.

I tried to fix the field’s configuration by manually adding it to all of the screens in my project (both through the UI and API) but still get " Field ‘customfield_10036’ cannot be set. It is not on the appropriate screen, or unknown."

I did find one interesting thing: if I call /rest/api/2/screens I get back this result:

"{"self":"https://stackdriver.atlassian.net/rest/api/2/sreen? It doesn't show up in the UI and I get a 404 if I try to DELcreens?maxResults=100&startAt=0","maxResults":100,"startAt":0,"total":5,"isLast":true,"values":[{"id":1,"name":"Default Screen"},{"id":2,"name":"Workflow Screen"},{"id":3,"name":"Resolve Issue Screen"},{"id":10000,"name":"SM: Simple Default Issue Screen","scope":{"type":"PROJECT","project":{"id":"10000"}}},{"id":10001,"name":"test screen"}]}"

which includes an unexpected entry “{“id”:10000,“name”:“SM: Simple Default Issue Screen”,“scope”:{“type”:“PROJECT”,“project”:{“id”:“10000”}}}”. This screen seems to be returned by this one call but doesn’t exist if I do anything else. For example, I can call /rest/api/2/screens//tabs for all screens except for screenid=10000. If I try to call rest/api/2/screens/10000/tabs I get “{“errorMessages”:[“Screen with id 10000 does not exist”],“errors”:{}}”. Is it possible this is what’s causing my createIssue error? Is there a way to delete a screen? It doesn’t show up in the UI and I get a 404 if I try to DELETE /rest/api/2/screens/10000.

Hrm, sorry i never saw this reply. You tagged this as Jira Server, but the JSON you’re providing is for Jira Cloud. The APIs are not the same and that could be causing the confusion here.