JIRA on creation of new issue

Hey mates,

today i was trying to create a new issue using REST API from JIRA and I always get the error:

HTTP/1.1 405 Method Not Allowed 

I am using OAuth authentication to create and edit issues. I already edit a few fields on issues that are already created, but now I am trying to create new issue.

URL

 https://xpto.pt/rest/api/2/issue/

 

JSON code

{
"fields": {
"project": {
"key": "ProjectKey"
},
"component": "CAIX - TEST 1",
"summary": "TESTE REQ. NAME",
"issuetype": {
"name": "Issue"
},
"labels": ["CASE-TEST", "REQUIREMENT", "Tests"]
}
}

 Note: i change the project key and page of JIRA for this example.

My url: 

My JIRA version is V7.1.9.

I already search and find that is another way to create issues using rest/api/2/issue/createmeta, but i dont want to use that.

 

Do you have any ideia of whats is wrong ? If necessary i can put put a example of the code.

1 answer

This widget could not be displayed.
Alexey Matveev Community Champion Oct 31, 2017

Hello,

REST API can send GET, POST, PUT, DELETE requests. Method Not Allowed usually means that you send a wrong request type. If you want to create an issue, it is a POST request. Make sure you make a POST request.

If the problem is not fixed kindly provide your code for making the request.

I already try the json example from JIRA API but the error still appears. See the code i am using

{
    "fields": {
       "project":
       { 
          "key": "TEST"
       },
       "summary": "REST ye merry gentlemen.",
       "description": "Creating of an issue using project keys and issue type names using the REST API",
       "issuetype": {
          "name": "Bug"
       }
   }
}


 

I Post via this code:

uri is the page: https://xpto.jira.com/rest/api/2/issue/

json2 is the example

 

HttpPut put = new HttpPut(uri);
HttpResponse response = null;
put.setHeader("Content-Type", "application/json");
put.setHeader("Authorization", "Basic " + args.getJiraAuthToken());
try {
HttpEntity entity = new ByteArrayEntity(json2.getBytes("UTF-8"));
put.setEntity(entity);
response = httpClient.execute(put);

}catch (Exception e){
System.out.println(e);
}finally {
return response;
}

 

 

 

Alexey Matveev Community Champion Oct 31, 2017

Replace new HttpPut(uri) with new HttpPost(uri)

Martin Varga Atlassian Team Oct 31, 2017

What @Alexej said. Also:

rest/api/2/issue/createmeta

is not used to create issues. This is the meta data documentation for the fields you are sending to the create endpoint. 

I already find the problem :)

Needed to change to HttpPost and need to change the IssueType.

 

@Martin Varga AND @Alexey Matveev Thanks for your help guys! If u need something from me, contact me :)

 

Suggest an answer

Log in or Sign up to answer
Atlassian Summit 2018

Meet the community IRL

Atlassian Summit is an excellent opportunity for in-person support, training, and networking.

Learn more
Community showcase
Posted 8 hours ago in New to Jira

Are you planning to trial, or are currently trialling Jira Software? - We want to talk to you!

Hello! I'm Rayen, a product manager at Atlassian. My team and I are working hard to improve the trial experience for Jira Software Cloud. We are interested in   talking to 20 people planning t...

21 views 0 0
Join discussion

Atlassian User Groups

Connect with like-minded Atlassian users at free events near you!

Find a group

Connect with like-minded Atlassian users at free events near you!

Find my local user group

Unfortunately there are no AUG chapters near you at the moment.

Start an AUG

You're one step closer to meeting fellow Atlassian users at your local meet up. Learn more about AUGs

Groups near you