Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

Jira REST API Create Issue

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~

4 answers

1 accepted

0 votes
Answer accepted

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");

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

1 vote

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)

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?

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?

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.

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

0 votes
rsperafico Atlassian Team Oct 20, 2015

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

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Posted in Jira Core

How to manage many similar workflows?

I have multiple projects that use variations of the same base workflow. The variations depend on the requirements of the project or issue type. The variations mostly come in the form of new statuses ...

4,257 views 12 5
Join discussion

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you