Hi ,
I am using google form to create an automatic jira task using Jira REST API. But i want to create that task inside a predefined Epic, so that it becomes easy to track the tasks.
Any help is highly appreciated.
In the issue you are creating, just add another field called"epic link" and set it with the epic you want.
Of course "epic link" should also be available in the create screen of the issue via the UI
Hi @Nir Haimov ,
I have below json and code , can you please help how to use epiklink to pass the data.
JSON:-
{
CODE:- few lines of code to send data.
var formattedDate = ''
var data = {}
var fields = {}
fields.project = { "key": "ABC" };
fields.summary= summary;
fields.labels= [system];
fields.description= description;
fields.priority = {"name": severity };
if (deadline != ''){
formattedDate = Utilities.formatDate(new Date(deadline), "EST", "yyyy-MM-dd");
fields.duedate = formattedDate;
2. I am unable to find epiclink in UI.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @sachin.sharma ,
First, you have to add "epic link" to the UI create screen, otherwise it will not work via REST API.
Once you add it, it your API use this body as example:
{
"fields": {
"project": {
"id": "12200" //your project id
},
"summary": "Nir API Test",
"issuetype": {
"id": "10100" //this is the id of "task"
},
"customfield_10001": "JAT-641" //customfield_10001 is "epic link" and replace "JAT-641" with you epic key
}
}
That's it, very simple
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
check the id of your "epic link" field, it might be something else, but API body should be the same concept
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Thanks for your support @Nir Haimov .
I did the same changes but getting below error.
"Exception: Request failed for https://test.net returned code 400. Truncated server response: {"errorMessages":[],"errors":{"customfield_10004":"Field 'customfield_10004' cannot be set. It is not on the appropriate screen, or unknown."}} (use muteHttpExceptions option to examine full response)"
Note:: Epic link field was customfield_1004.
My code is :-
var fields = {}
fields.project = { "id": "18858" };
fields.customfield_10004= "ABC-81";
fields.summary= summary;
fields.labels= [system];
fields.description= description;
fields.priority = {"name": severity };
if (deadline != ''){
formattedDate = Utilities.formatDate(new Date(deadline), "EST", "yyyy-MM-dd");
fields.duedate = formattedDate;
}
if (reporterId){
fields.reporter= {"id": reporterId}
}
fields.environment = env;
fields.issuetype = {"name": "Task" };
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Your code is fine, the problem is in Jira.
You just need to add "Epic Link" to the create issue screen in Jira.
Te field have to be available in the UI action so you will be able to do it also from the REST API.
Let me know if you still encounter problems after adding the field.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @Nir Haimov ,
Since than i have been trying to find "How to create an epic link but no luck!"
One Quick question :- Creating an epic and using its url will work as epik link?
Please forgive me if i am asking something stupid.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Hi @sachin.sharma ,
You tried to create epic via REST API or by the UI?
You can't use the epic link url as epic link, you need to use the epik issueKey (ABC-123)
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
Yaah , it means i am in the right direction.
i have done the same thing , i have created an epic using UI and used its issue key in the code but didn't get success . As you can check in my code above https://community.atlassian.com/t5/Jira-questions/How-to-create-a-task-inside-an-Epic-using-Jira-Rest-API/qaq-p/1348846?utm_campaign=accept_as_solution_reminder&utm_content=view-answer&utm_medium=email&utm_source=atlcomm#
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.
@sachin.sharma i don't understand your code above, seems like you sending unnecessary data...
try first to create simple issue with the code i sent to you above, once that works, the rest is just a bit tuning with your code...
The code i sent you work, i tested it with my instance before sending to you, if that's not work for you, you are doing something wrong again....
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.