I'm using JIRA cloud.
Trying to use the API to create JIRA issues, but I got following error when I tried to set the summary field.
{"errorMessages":[],"errors":{"summary":"Field 'summary' cannot be set. It is not on the appropriate screen, or unknown."}}
final ClientConfig clientConfig = new ClientConfig(); final BasicAuthSecurityHandler basicAuthHandler = new BasicAuthSecurityHandler("username", "password"); clientConfig.handlers(basicAuthHandler); final RestClient winkClient = new RestClient(clientConfig); final Resource resource = winkClient.resource("https://cnwyjira.atlassian.net/rest/api/2/issue"); final ClientResponse response = resource .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON) .post("{\"fields\":{\"project\":{\"id\":\"10001\"},\"issuetype\":{\"id\":\"10000\"},\"summary\":{\"JiraRestAPI\"}}}"); System.out.println(response.getEntity(String.class));
However, I was able to update the summary field by creating an new issue first via JIRA UI.
final Resource resource = winkClient .resource("https://cnwyjira.atlassian.net/rest/api/latest/issue/EDI-19604"); final ClientResponse response = resource .contentType(MediaType.APPLICATION_JSON) .accept(MediaType.APPLICATION_JSON) .put({\"fields\":{\"summary\":\"REST API Updated Summary\"}});
Please help! Thanks~
Thanks for the answers everyone.
I've found what caused this problem which was Authorization issue.
I should have done:
final RestClient winkClient = new RestClient(); final Resource resource = winkClient.resource("https://cnwyjira.atlassian.net/rest/api/latest/issue"); final String loginInfo = "username:password"; final String encodedLogin = new BASE64Encoder().encode(loginInfo.getBytes()); resource.header("Authorization", "Basic " + encodedLogin);
Instead of:
final ClientConfig clientConfig = new ClientConfig(); final BasicAuthSecurityHandler basicAuthHandler = new BasicAuthSecurityHandler("username", "password"); clientConfig.handlers(basicAuthHandler); final RestClient winkClient = new RestClient(clientConfig); final Resource resource = winkClient.resource("https://cnwyjira.atlassian.net/rest/api/latest/issue");
The clue is in the error message.
You can create issues with a summary with your "Create" code, so that tells us your "create issue" screen has the summary on it. The error message is complaining that it can't find the field on your "edit" screen though. So you need to add the summary to the edit screen.
Go to the project and drill down through its configuration (Issue type screen scheme -> screen scheme -> screen)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I do have summary field setup in both create and edit view for the project. When I clicked "Create" button on Jira UI, the popup window has the summary field and is required. But if it's in create dialog, the first page has project and issue type fields and need to click "next" to see the summary field. Would that be the reason why I got the error?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Sorry, I got my answer the wrong way around. The system thinks the summary is missing from create, not edit. The two step creation process should not be the problem though - REST should see the whole create screen in one go, with the summary on it, but that gives me a nagging doubt - what version of JIRA are you on? And is the summary on the create screen for *all* the issue types in that project?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
All issue types have summary field setup and I'm using Jira 7 cloud. Same error happened when I tried to set the description field... Looks like I can only set project and issue type fields that really makes me wonder if it's the two step creation cause the problem.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I'm a bit stuck then - REST creates issues fine on my Cloud installation. I've used curl as shown in the docs, but I can't see how your code would fail
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Is your 'summary' field is available and enabled on "create issue" screen? It should be available and enabled, otherwise you cannot set it from REST API
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hello Mitch Lu,
Thank you for your question.
Based on the source-code you have provided, we can notice you are setting up "summary" value as an object whereas the same should be a String.
.post("{\"fields\":{\"project\":{\"id\":\"10001\"},\"issuetype\":{\"id\":\"10000\"},\"summary\":{\"JiraRestAPI\"}}}");
{ "fields": { "project": { "id": "10001" }, "issuetype": { "id": "10000" }, "summary": { "JiraRestAPI" } } }
Please, refer to Examples of creating an issue that suggests the following data:
{ "fields": { "project": { "key": "TEST" }, "summary": "REST ye merry gentlemen.", "description": "Creating of an issue using project keys and issue type names using the REST API", "issuetype": { "name": "Bug" } } }
If you find this answer useful, I would kindly ask you to accept it so the same will be visible to others who might be facing the same issue you have inquired.
Thank you for your understanding.
—
Kind regards,
Rafael P. Sperafico
Atlassian Support
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.