1

I have this code on python 3.8:

from atlassian import Jira
jira = Jira(
        url='http://jira.mydomain.com/',
        username='login',
        password='password')
summary = 'Test summary'
description = 'Test description'
current_date = datetime.date.today()
duedate = datetime.datetime.strftime(current_date, "%Y-%m-%d")

fields = {"project": {"key": 'ARL'},
          "summary": summary,
          "description": description,
          "issuetype": {"name": "Task"},
          "duedate": duedate,
          "labels": ["Demo"],
          "components": [{"name": "Selary"}]
             }

_____________________________________
And it return me this error:

Creating issue "Test summary"
Traceback (most recent call last):
  File "C:\Users\Max\PycharmProjects\GSheets-Test\venv\lib\site-packages\atlassian\rest_client.py", line 436, in raise_for_status
    j.get("errorMessages", list()) + [k.get("message", "") for k in j.get("errors", dict())]
  File "C:\Users\Max\PycharmProjects\GSheets-Test\venv\lib\site-packages\atlassian\rest_client.py", line 436, in <listcomp>
    j.get("errorMessages", list()) + [k.get("message", "") for k in j.get("errors", dict())]
AttributeError: 'str' object has no attribute 'get'

During handling of the above exception, another exception occurred:

Traceback (most recent call last):
  File "C:\Users\Max\PycharmProjects\GSheets-Test\test.py", line 37, in <module>
    print(jira.issue_create(fields_arl))
  File "C:\Users\Max\PycharmProjects\GSheets-Test\venv\lib\site-packages\atlassian\jira.py", line 1402, in issue_create
    return self.post(url, data={"fields": fields})
  File "C:\Users\Max\PycharmProjects\GSheets-Test\venv\lib\site-packages\atlassian\rest_client.py", line 333, in post
    response = self.request(
  File "C:\Users\Max\PycharmProjects\GSheets-Test\venv\lib\site-packages\atlassian\rest_client.py", line 257, in request
    self.raise_for_status(response)
  File "C:\Users\Max\PycharmProjects\GSheets-Test\venv\lib\site-packages\atlassian\rest_client.py", line 440, in raise_for_status
    response.raise_for_status()
  File "C:\Users\Max\PycharmProjects\GSheets-Test\venv\lib\site-packages\requests\models.py", line 960, in raise_for_status
    raise HTTPError(http_error_msg, response=self)
requests.exceptions.HTTPError: 400 Client Error: Bad Request for url: http://jira.mydomain.com/rest/api/2/issue

When i use project key from my second project - the issue is being created successfully According to information from the JIRA administrator these projects have the same business scheme and a set of required fields. The component in field exists too Same error rase if I pass an incorrect component name to the second project

what causes the error? What project/field settings can I check?

try another login-password - fail try second project - successful

Max Chupin
  • 11
  • 3
  • Probably the structure of your issue object does not match what is expected by Jira for this project. Maybe some field has complex type and you pass string instead so you get an error "'str' object has no attribute 'get'". Can you try to fetch an another existing issue from this project in Python code to see what is its structure? – dimnnv Mar 09 '23 at 09:09
  • the error is this: `HTTPError: 400 Client Error: Bad Request for url: http://jira.fisgroup.ru/rest/api/2/issue` . . . the site does not exist ! – D.L Mar 09 '23 at 09:42
  • Sorry, I forgot to fix it in the description . The site exists - let's say the address is the same as in the Jira object http://jira.mydomain.com/ – Max Chupin Mar 09 '23 at 11:02

1 Answers1

0

I fetch the fields from the existing issue, as advised in the comments. The name of the component in the project that I passed to the request differs from the actual one. Although I took the name from the Jira UI in UI was "Selary" in existing issue was " Selary " in DB was " Selary"

Max Chupin
  • 11
  • 3