I've used below command with no success. I couldn't create subtask using below syntax. Please help me in fixing this
Request:
curl -D- -u project-db:projectdbtest -X POST --data {""fields"":{""project"":{"key": "DT"},""parent"":{"key":"DT-33"},""summary"":"Test",""issuetype"":{"id":"53"}}} -H "Content-Type: application/json" http://jira2.com/rest/api/2/issue/
Response:
HTTP/1.1 400 Bad Request
Server: Apache-Coyote/1.1
X-AREQUESTID: 1381x497449x1
Set-Cookie: JSESSIONID=7E6AEAE7A75CF772B0F201417604AE51; Path=/; HttpOnly
X-Seraph-LoginReason: OK
Set-Cookie: atlassian.xsrf.token=AGWG-LFJC-4AYE-UW3X|f3114f62546ec709c9f262291fd2311a7d3f6fd8|lin; Path=/
X-ASESSIONID: nusqd4
X-AUSERNAME: project-db
Cache-Control: no-cache, no-store, no-transform
Content-Type: application/json;charset=UTF-8
Transfer-Encoding: chunked
Date: Tue, 20 May 2014 06:01:16 GMT
Connection: close
{"errorMessages":["Unexpected character ('f' (code 102)): was expecting double-quote to start field name\n at [Source: org.apache.catalina.connector.CoyoteInputStream@596d22e; line: 1, column: 3]"]}
Community moderators have prevented the ability to post new answers.
Hi Raghuvamsi,
I stronly suggest you use a http REST client (like Google's postman Chrome plugin), because this tool makes you life much easier :)
In the following usecase I made a project with project key TEST. My jira instance is running on the localhost (base url: http://localhost:2990/jira). To create a subtask using REST do the following:
1) Create an issue to which you want to attach a subtask:
{ "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" } } }
Result:
2) Create a sub-task and attach it to the issue from step 1:
Content: { "fields": { "project": { "key": "TEST" }, "parent": { "key": "TEST-1" }, "summary": "Sub-task of TEST-1", "description": "Don't forget to do this too.", "issuetype": { "id": "5" } } }
Result:
This tutorial was based on a tutorial from Atlassian that gives more info on REST API usage:
https://developer.atlassian.com/display/JIRADEV/JIRA+REST+API+Example+-+Create+Issue#JIRARESTAPIExample-CreateIssue-Exampleofcreatinganissueusingprojectkeysandfieldnames
Hope this helps?!
{ "expand": "projects", "projects": [ { "self": "http://localhost:2990/jira/rest/api/2/project/10000", "id": "10000", "key": "TEST", "name": "test", "avatarUrls": { "16x16": "http://localhost:2990/jira/secure/projectavatar?size=xsmall&pid=10000&avatarId=10011", "24x24": "http://localhost:2990/jira/secure/projectavatar?size=small&pid=10000&avatarId=10011", "32x32": "http://localhost:2990/jira/secure/projectavatar?size=medium&pid=10000&avatarId=10011", "48x48": "http://localhost:2990/jira/secure/projectavatar?pid=10000&avatarId=10011" }, "issuetypes": [ ... { "self": "http://localhost:2990/jira/rest/api/2/issuetype/5", "id": "5", "description": "The sub-task of the issue", "iconUrl": "http://localhost:2990/jira/images/icons/issuetypes/subtask_alternate.png", "name": "Sub-task", "subtask": true }, ... ] } ] }
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
NOTE: This REST call gives you an overview of all projects with their available issue types (and id):
http://localhost:2990/jira/rest/api/2/issue/createmeta
For instance the issuetype field in the JSON request bodies refer to an id from this REST API output (GET request):
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks a lot. POSTMAN plugin really helped me in tracing out the issue.
The issue is not taking Description field . Appreciate your help.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.