Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Status Code 400

fza June 17, 2019

Hello folks,

I am trying to create an issue in Jira with the REST API. I keep getting a 400 error with this response:

{"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."}}

 

I cant figure out the issue. I believe my JSON string is exactly like the one provided by Jira, this is what it looks like:

{"fields":{"summary":"Test POST","issuetype":{"id":"10002"},"project":{"key":"key"},"description":"Testing if this POST request will work."}}

 

I am using the right authentication credentials, yet it keeps giving me this error. Here is a code snippet of my request in Java:

String headerVal = USERNAME + ":" + API_TOKEN;
String authorizationHeader = "Basic " + Base64.getEncoder().encodeToString(headerVal.getBytes("utf-8"));


HttpHost proxy = new HttpHost("host", port);
Credentials credentials = new UsernamePasswordCredentials("user","password");
AuthScope authScope = new AuthScope("host", port);
CredentialsProvider credsProvider = new BasicCredentialsProvider();
credsProvider.setCredentials(authScope, credentials);
HttpClient client = HttpClientBuilder.create().setProxy(proxy).setDefaultCredentialsProvider(credsProvider).build();

HttpPost request = new HttpPost(ENDPOINT);

request.setHeader("Authorization", authorizationHeader);
request.setHeader("Content-Type", "application/json");
request.setHeader("Accept", "application/json");
StringEntity params = new StringEntity(testIssue.toString());
request.setEntity(params);

HttpResponse response = client.execute(request);

 

1 answer

0 votes
Ilya Turov
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.
June 17, 2019
fza June 18, 2019

Hi Ilya,

Thanks for the response. I just tried doing a PUT method and it is now giving me a 405 error. BTW, I am trying to create a new issue not update one.

Any suggestions?

fza June 18, 2019

I just did a GET call to check my permissions, and it says I dont have permission to create issues, but I am using the same account that I use on Jira's website which is a site admin and has full access. 

Why would the REST API return that I dont have permission?

Ilya Turov
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.
June 18, 2019

@fza 

sorry, didn't notice late at the evening that you are creating an issue, not updating

POST is correct method here, my bad.

I guess the fields are present on the issue creating screen and the user you are trying to perform it from has the necessary rights to create an issue?

Also, Im not really getting the double authentication, but guess since you are getting the jira error, the first one works alright.

fza June 18, 2019

Yes, the fields I am trying to fill in are all present for me on the Jira website and the account has permissions to do so. I know this also because i used the same account on another project and it worked. 

For the two authentications you're seeing, the first one is to authenticate myself on the company proxy. 

The second one is as you can see, basic auth for Jira. 

I still havent been able to figure out why I am getting this error and why the API says this account doesnt have permission.

Suggest an answer

Log in or Sign up to answer