Hello,
I am trying to make POST requests to the Jira REST API, however when I try to create an issue, it gives me a 400 error with:
{"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."}}
My JSON is exactly like the example ones Atlassian provides, so I checked my user permissions through the REST API. It returns that the account does not have permission to create an issue, but the account Im using is a site admin and has full access to do anything in my instance of Jira.
When I try to get session info, it returns this:
{"errorMessages":["You are not authenticated. Authentication required to perform this operation."],"errors":{}}
I am confused as to why I'm not getting authenticated when I have a basic auth header in my request. Here is a snippet of my code in Java:
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("https://myinstance.net/rest/auth/latest/session");
String headerVal = USERNAME + ":" + API_TOKEN;
String authorizationHeader = "Basic " + Base64.getEncoder().encodeToString(headerVal.getBytes("utf-8"));
request.addHeader("Content-Type", "application/json");
request.addHeader("Accept", "application/json");
StringEntity params = new StringEntity(testIssue.toString());
request.setEntity(params);
request.addHeader("Authorization", authorizationHeader);
HttpResponse response = client.execute(request);The first bit of authentication is for my company proxy, for some reason Eclipse wouldn't hit the proxy so I had to force my code to go through it, hence the proxy stuff and authentication. The second bit of authentication is in the header for the Jira request.
I have a feeling my proxy procedures are messing with my authentication, because I know this account has access to everything, as I have used it before for another project using the rest api and it worked.
Can anyone offer any suggestions or ideas? I have been stuck on this for a day or two.