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.
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;
}
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Replace new HttpPut(uri) with new HttpPost(uri)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
What @Alexej_G 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.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
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 :)
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.