JIRA REST 5.0 - Create Issue Error

Steffen Karlsson April 15, 2012

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?

15 answers

4 votes
Steffen Karlsson April 17, 2012

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..

Jebb Domingo April 22, 2013

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.

Arthur
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
August 28, 2013

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

akshay_chalana September 20, 2016

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.
Sam lee March 28, 2019

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

manik June 29, 2019

I'm having the same issue with python library

Like # people like this
Fresh Life Floral July 31, 2019

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 # people like this
Fresh Life Floral July 31, 2019

what should I do

Like # people like this
2 votes
Arthur
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
September 11, 2013

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

1 vote
s2zaman July 8, 2015

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.

Brian Richardson June 26, 2017

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

 

1 vote
Michael Woyowd September 11, 2013

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
....

1 vote
Raju KC
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 21, 2013

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

0 votes
Matt Duguid February 23, 2021

We had similar errors,

errors":{"xyz":"Field 'xyz' cannot be set. It is not on the appropriate screen, or unknown."}}

The cause for us was definitely authorisation and not our json body or fields.

We were passing in an old token in the authorisation header of the API post, it wasn't until we base64 decoded it and compared that we realised the mistake.

0 votes
priyank ghedia February 8, 2021

I had the same issue. It ended up being a permissions issue (the error message is not helpful, I had to remove all the fields except for 'key' and 'issue type' to find this out). Make sure your users role/groups has permission. You can check in administration-->issue-->permission schemes. Check 'create issues' project permission, if not then add, and hopefully it works. Instructions here 

0 votes
Dobrivoje Prtenjak January 29, 2020

Well, I'm able to create issue in Postman, both using POST requests in either OAuth 1.0 and Basic authentication calls.
In Java Spring boot project, there is a mandatory to use OAuth 1.0, and although I use all get API call without any errors, I still don't know how to make a POST request for creating new issue.

0 votes
Adrian Jardinez Calderon December 9, 2019

Same issue on Postman, my error was inheriting credentials from another request

0 votes
lakshmi September 21, 2019

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="          },

0 votes
IonelLupu August 24, 2018

Any updates on this?

0 votes
Wendy Meng May 5, 2013

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

0 votes
Dieter
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2012
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
0 votes
RambanamP
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2012

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

0 votes
Renjith Pillai
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
April 17, 2012

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

Suggest an answer

Log in or Sign up to answer