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 5.0 - Create Issue Error

Hello

Right now im trying to make an application for JIRA, im upgrading from using SOAP RPC to using the newest REST api, and all the GET methodes work perfectly.

Now im trying to make POST methodes works properly. But when im trying to create a new issue using: http://docs.atlassian.com/jira/REST/latest/#id161572 it all breaks.

Im getting this 400 Eror: {"errorMessages":[],"errors":{"summary":"Field 'summary' cannot be set. It is not on the appropriate screen, or unknown.","priority":"Field 'priority' cannot be set. It is not on the appropriate screen, or unknown.","description":"Field 'description' cannot be set. It is not on the appropriate screen, or unknown."}}

It supposed to be a JSON format exception, but when i look at my JSON post form with data, it perfectly match the requriments at their API site. I even try to copy that data they use there, and still get the error.

So my question is, have you any idea what i do wrong?

11 answers

The solution has been found :)

The HTTP Basic Session Cookie just need to be preemptive:

httpRequest.addHeader(new BasicScheme().authenticate(new UsernamePasswordCredentials("username","password"), httpRequest));

Jira says its a JSON format problem, but it is a auth-error. Hope it helps other people..

How to properly do it in PHP CURL? I tried to invoke curl_setopt(handle, CURLOPT_USERPWD, "user:password") again but still throws the same error.

I have the same problem, but I use jquery ajax to call this rest functions. Any idea what I can do to solve this?

According to this StackOverflow answer, this is the default setting for cURL authentication.  It can be forced by including this line before the authentication line:

curl_setopt($ch, CURLOPT_HTTPAUTH, CURLAUTH_BASIC);
As such, it's unlikely that the problem is authentication in the PHP cURL context. Nevertheless, in order to test this, one suggestion would be to try using a different requests library, like HTTP_Request2 or GuzzleHTTP.

 I have the same problem, but I use python to call this rest functions. Any idea what I can do to solve this?

I'm having the same issue with python library

Like a.lepkin likes this

The server returned the following errors:

  • Field 'summary' cannot be set. It is not on the appropriate screen, or unknown.
  • Field 'priority' cannot be set. It is not on the appropriate screen, or unknown.

 

Since Capure for jira

Like Said Kouzibry likes this

The authentication can be the problem, but it can also be another problem: You should look which fields are visible when you press "create issue". When you try to create an issue with the REST API you may only set the fields that are visible in that screen.

I had the same problem, and solved it by adding the needed fields to the create issue screen: https://answers.atlassian.com/questions/207159/how-to-use-rest-api-to-create-issue-in-gadget

got the same problem.

like steffenkarisson said, its an authentication problem. i solved this by authenticate the user before creating the issue.

DefaultHttpClient client = new DefaultHttpClient();
			
HttpGet getRequest = new HttpGet(url + "rest/auth/latest/session");
getRequest.addHeader("Authorization", "Basic " + userToken);
getRequest.addHeader("accept", "application/json");
HttpResponse getResponse = client.execute(getRequest);

HttpPost postRequest = new HttpPost(....);  // start to send the issue
....

When getting errors like;

"reporter": "Field 'reporter' cannot be set. It is not on the appropriate screen, or unknown."

"assignee": "Field 'assignee' cannot be set. It is not on the appropriate screen, or unknown."

"summary": "Field 'summary' cannot be set. It is not on the appropriate screen, or unknown."


Solution: (you should create screen permission before creating issue with the code, only if you are creating it with the code)

Solution 1: 1st solution is the same as @Ravi Somisetty provided on this same page.

Solution 2: Here i will elaborate @Nic Brough [Adaptavist]'s answer.

Verify if the "reporter" or "assignee" or "summary", exists on the 'Create Issue'.

You may find the 'Create Issue' as;

  • Go to your JIRA project main page.
  • Click the "Project administration" , on the bottom of left sidebar.
  • Select the "Screens"  from left sidebar.
  • Now click the "Default Screen" . .
  • Here is your "Create Issue" screen.
  • Add any field that is missing.
  • ......and your code should succeed.

Yup, banged my head on this for a couple of hours.... the message is deceiving. It turned out that it was an authentication issue. In my case I was injected the Base64 encrypted key right into the header - overlooking it as I did not get an authentication error and used the same hash on my rest client plugin -  no issues there... on a whim on decided to hash the auth piece in code then pass it in my request. Worked like a charm - Jira please provide a more friendly and intuitive error! Cheers

const auth = 'Basic ' + new Buffer('usr' + ':' + 'pass').toString('base64');
Authorization': auth

 

But the error seems to clearly state that the mandatory fields are missing in the request. Can you post the code fragment?

error message saying that summary,priority and description fields are not there on the screens

Did you already try the tutorial https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue As Renjith says it would be good to see your request

I got the same error when creating an issue ticket by using REST API.

{"errorMessages":[],"errors":{"summary":"Field 'summary' cannot be set. It is not on the appropriate screen, or unknown.","description":"Field 'description' cannot be set. It is not on the appropriate screen, or unknown."}}

Here is my cod. Do I missing anything or have wrong field name?

String jiraHost = "https://xxxx/rest/api/2/issue/";

<font></font>

String data =

<font></font>

"{\"fields\":"+

"{\"project\":{\"key\": \"BTBA\"}," +

"\"summary\":\"PMD - Asset folders.\"," +

"\"Description\": \"Creating of an issue using project keys and issue type names using the REST API\", " +

"\"issuetype\": {\"name\":\"Bug\"}}}"

;

<font></font>

HttpClient client =

<font></font>

new

DefaultHttpClient();

client = WebClientWrapper.getSSLClient(client);

<font></font>

HttpPost post =

<font></font>

new HttpPost(jiraHost

);

<font></font>

StringEntity entity =

<font></font>

new

StringEntity(data);<font></font>

entity.setContentType(

<font></font>

"application/json"

);

post.setEntity(entity);

HttpResponse response = client.execute(post);

Any sollution for this................

Any updates on this?

I have encountered the same issue , it was authentication issue as suggested.

Just postman to see the Basic authentication and username and password

copied the "authorization" : "Basic ...."

to my code in header i.e i m using loopback connector to connect to create issue in jira.

"headers": {            "accepts""application/json",            "content-type""application/json",            "authorization":"Basic wdsdssds="          },

Suggest an answer

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

Demo Den Ep. 7: New Jira Cloud Reports

Learn how to use two new reports for next-gen projects in Jira Cloud:  Cumulative flow diagram and Sprint burndown chart. Ivan Teong, Product Manager, Jira Software, demos the Cumulative ...

260 views 1 2
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