POST request to JIRA REST API to create issue of type Minutes

Arjun February 8, 2022
my $url2 = 'https://url.com:123/rest/api/2/issue';
my $create_issue_json = '{"fields": { "project": { "key": "NCG3D" }, "summary": "summary of my first issue", "versions": [{"Affects Versions/s": "v2.1"}, {"name": "v2.1"}], "Brands": ["Opel"], "components": "SW_VERSION", "description": "Creating an issue via REST API", "issuetype": { "name": "Minutes" }}}';

$tx1 = $jira_ua->post($url2 => json => decode_json($create_issue_json));
my $res1 = $tx1->res->body;

The above produces the following output

{"errorMessages":["Brands: Brands is required.","Detection: Detection is required."],"errors":{"components":"Component/s is required."}}

But these fields are available only in issue of type bug and not for type Minutes.

2 answers

1 accepted

0 votes
Answer accepted
Arjun February 14, 2022

Sorry, this is due to the configuration issue at Jira Admin side which I wasn't aware of before and now I've requested to correct(to remove mandatory option for Brands and Detection) and it works okay now.

0 votes
Pramodh M
Community Leader
Community Leader
Community Leaders are connectors, ambassadors, and mentors. On the online community, they serve as thought leaders, product experts, and moderators.
February 8, 2022

Hi @Arjun 

Welcome to the Community!!

I'm mesmerized by the API Call

Can you try the below API and let me know if it works

pip install atlassian-python-api


jira = Jira( url='https://your-jira-instance.company.com', token=jira_access_token )

fields
= {'summary': 'New summary'} jira.issue_create(fields)

https://atlassian-python-api.readthedocs.io/jira.html

https://developer.atlassian.com/cloud/jira/platform/rest/v3/api-group-issues/#api-rest-api-3-issue-post

Thanks

Arjun February 8, 2022

@Pramodh M

from atlassian import Jira

jira = Jira( url='https://jira.instance.com', token='used PAT token' )

fields = {'project': 'sample', 'summary': 'sample issue'}
jira.issue_create(fields)

produces below o/p:

(base) D:\scripts>python issue.py
Creating issue "sample issue"
Traceback (most recent call last):
File "issue.py", line 6, in <module>
jira.issue_create(fields)
File "C:\Users\aeu5cob\AppData\Roaming\Python\Python38\site-packages\atlassian\jira.py", line 1166, in issue_create
return self.post(url, data={"fields": fields})
File "C:\Users\aeu5cob\AppData\Roaming\Python\Python38\site-packages\atlassian\rest_client.py", line 309, in post
response = self.request(
File "C:\Users\aeu5cob\AppData\Roaming\Python\Python38\site-packages\atlassian\rest_client.py", line 242, in request
self.raise_for_status(response)
File "C:\Users\aeu5cob\AppData\Roaming\Python\Python38\site-packages\atlassian\rest_client.py", line 399, in raise_for_status
raise HTTPError(error_msg, response=response)
requests.exceptions.HTTPError: project: project is require

 

Suggest an answer

Log in or Sign up to answer