Hello,
I am trying to create a new project in Jira cloud using Java Jira Rest API but it gives me an error: Exception in thread "main" java.lang.NoSuchFieldError: INSTANCE.
I have removed the older versions of http client from my classpath but nothing changes.
Can anyone help me to find out where is the problem or any other sample code that works for create a new project in jira?
Note: I have used Basic Authentication:
Username: My email adress
Pasword: My Jira account pasword
In the attach there are the code that I have used, the error it produces and the jars.
Try the username. Its under the Profile Summary of your account.
Your code is feeding your Jira instance a field that does not exist. Try not sending that pointlessly, it should work fine then.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
I am using another sample code to cretate a project:
try {
Client client = Client.create();
client.addFilter(new HTTPBasicAuthFilter("ing.eln94@gmail.com", "1M3GaUNXMVIpsRdrWq3p011B"));
WebResource webResource = client.resource("https://aplikim.atlassian.net/rest/api/2/project");
String input="{\"key\": \"EX\",\"name\": \"Example\",\"projectTypeKey\": \"business\", \"projectTemplateKey\": \"com.atlassian.jira-core-project-templates:jira-core-simplified-project-management\",\"description\": \"Example Project description\", \"lead\": \"ing.eln94@gmail.com\", \"url\": \"https://atlassian.com\",\"assigneeType\":\"PROJECT_LEAD\",\"avatarId\":10200}" ;
ClientResponse response = webResource.type("application/json").post(ClientResponse.class, input);
String output = response.getEntity(String.class);
System.out.println("Output from Server .... \n");
System.out.println(output);
} catch (Exception e) {
System.out.println("oii");
e.printStackTrace();
}
but it gives me the output:
I have specified the projectLead: \"lead\": \"ing.eln94@gmail.com\".
Can you help me to find out the problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You need to give the lead as a user id, not an email address
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You mean username?
For example, as shown in the image I have created some projects and I am the leader.
When I use : \"lead\": \"Ing\" it gives me the same error
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
So "Ing" is not the username, or if it is, it's someone who can't be set as a project lead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
But "Ing" is the admin and when I create a project manually by using the Create New Project button in Jira it creates succesfully. I want to use Java code because I want to create multiple projects. So where is the problem?
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
The problem is that you're not giving it a valid user for the project lead.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi,
Are you using JIRA Server or JIRA Cloud?
If yes, I would suggest using REST API instead: https://developer.atlassian.com/cloud/jira/platform/rest/v3/#api-api-3-project-post
I do not know if the JAVA API works with JIRA Cloud.
Regards.
---Update---
Just saw you are calling the rest api over Java, may I ask why and why you are not using a simple curl to test first?
Let's start from there and confirm you have this working correctly and not throwing an error.
I have not tested from Java and would need to look at this further.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Online forums and learning are now in one easy-to-use experience.
By continuing, you accept the updated Community Terms of Use and acknowledge the Privacy Policy. Your public name, photo, and achievements may be publicly visible and available in search engines.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.