Forums

Articles
Create
cancel
Showing results for 
Search instead for 
Did you mean: 

Create tasks using REST API

Lukaš Koribsky January 4, 2021

Hi all,

I'm trying to create tasks in R language using REST API for Jira.

This issue don't relate to the using POST call in R, but overall URL link for crearing issue  which could be used also in web browser.

I manage to fill basic mandatory fields, but I have issue selecting specific option from the list of options of custom fields.

Link for creating user story is following:

https://*domain+jira*/secure/CreateIssueDetails!init.jspa?pid=14500&issuetype=11001&summary=say+hello+world&customfield_10200=245&customfield_10201=30

 I get only error about missing mandatory fields

customfield_10200: Account is required.

customfield_10201: Team is required.

Did I miss something in the specification of custom field option?

Thank you for the support

3 answers

2 accepted

1 vote
Answer accepted
Martin Bayer _MoroSystems_ s_r_o__
Community Champion
January 4, 2021

Hi @Lukaš Koribsky , welcome on the community. I can see you want to "create issue from browser" but you can simply invoke only GET request in browser (I think it is what you want), but you are trying to use action CreateIssueDetails which can handle only POST request. Also native Jira REST API for issue creation uses POST request (https://docs.atlassian.com/software/jira/docs/api/REST/8.13.2/#api/2/issue-createIssue).

I think you can still create issue via GET request but you would need to implement simple endpoint which will accept GET request.

Lukaš Koribsky January 4, 2021

Hi @Martin Bayer _MoroSystems_ s_r_o__  thank you. I understand what do you mean. I didnt already try to fill fields through JSON. I found somewhere that sending POST request with CreateIssueDetails structure is also possible way to create issues.

Now I will focus only to generate it through POST (according to the documentation which doy reference to me)

Thank you

0 votes
Answer accepted
Gonchik Tsymzhitov
Community Champion
January 4, 2021

Hi!

Could you check your request via postman, please?

Also, you can find some info from dev tools from your browser. If you creat test ticket you can find the exact POST request.

0 votes
Lukaš Koribsky January 17, 2021

Hi again,

so I checked structure of task which were already created in my team, and according that I created following JSON:

{
"fields": {
"project":
{
"id": "14400"
},
"summary": "TEST US",
"description": "Creating of an issue using IDs for projects and issue types using the REST API",
"issuetype": {
"id": "10001"
},
"customfield_11400": {
"self": "https://*JIRA+domain*/rest/api/2/customFieldOption/13703",
"value": "Standard",
"id": "13703"
},
"customfield_10201": "30",
"customfield_10200": {
"self": "https://*JIRA+domain*/rest/tempo-accounts/1/account/245",
"id": "245",
"key": "TESTPROJEC",
"name": "Test project"
}
}
}

Using POST call:

post <- httr::POST( "https://*JIRA+domain*//rest/api/2/issue"
, body = toJSON(list(body = test), auto_unbox = T)
, content_type_json()
, authenticate(user, password))

But I get only 404.

 

Is there any way, how can I find out what exactly is wrong? Or my JSON is wrong?

customfield_11400, customfield_10200, customfield_10201 are mandatory fields.

Thank you for the support.

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
January 17, 2021

@Lukaš Koribsky try to change endpoint to 

https://*JIRA+domain*/rest/api/3/issue
Lukaš Koribsky February 9, 2021

@Martin Bayer _MoroSystems_ s_r_o__  sorry for late response. I tried that, but it returns HTTP 404 with message about dead link.

I have a question: if I try to put 

https://*JIRA+domain*/rest/api/2/issue

 to web browser, it okay/expected to receive this:

restApi.PNG

I dont have experience with REST API, that on the background will process some functionality for creating something, but I was expecting maybe something different.

Thank you for the support

Martin Bayer _MoroSystems_ s_r_o__
Community Champion
February 16, 2021

Hi @Lukaš Koribsky , you need to replace 

*JIRA+domain*

with a value relevant for you... probably something like "yourcompany.atlassian.net".

Lukaš Koribsky February 17, 2021

Hi @Martin Bayer _MoroSystems_ s_r_o__ yes, this was correct.

Anyway, the issue was only and only in the json. For the specific custom_field I have to send only ID of value. No label of value, or anything else, just ID.

Anyway Thank you all for support

Suggest an answer

Log in or Sign up to answer