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