Hi everybody,
Just starting this journey with Jira and struggling when I try to create an issue through a Python code. The error I get from the API as follows:
{"errorMessages":["Invalid request. Could not parse request body."]}
Does anybody know why this happen and how to fix it?
Here is my code:
jiraurl = "https://domain.atlassian.net/rest/api/3/issue"
jiraheaders = { 'Content-Type': 'application/json', }
jj= json.dumps({
"fields": { "project":{ "key": "MY_KEY" }, "summary": "My first issue created", "description": "My issue description", "issuetype": { "name": "Incident" } } })
response = requests.post('https://domain.atlassian.net/rest/api/3/issue', headers=jiraheaders, json=jj, auth=('email', 'token))
Now, if I try run the same command over cURL, it works perfectly:
curl -D- -u email@token -X POST --header 'Content-Type: application/json' --data '{"fields":{"project":{"key": "MY_KEY"},"summary": "My first issue created","description":"My issue description","issuetype":{"name":"Incident"}}}'https://domain.atlassian.net/rest/api/2/issueHTTP/1.1 201 CreatedDate: Fri, 17 Jun 2022 16:25:48 GMTContent-Type: application/json;charset=UTF-8Server: globaledge-envoyTiming-Allow-Origin: *X-Arequestid: request_IDSet-Cookie: atlassian.xsrf.token=cookie; path=/; SameSite=None; SecureX-Aaccountid: Account_IDCache-Control: no-cache, no-store, no-transformVary: Accept-EncodingX-Envoy-Upstream-Service-Time: 960Expect-Ct: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/atlassian-proxy", max-age=86400Strict-Transport-Security: max-age=63072000; preloadX-Content-Type-Options: nosniffX-Xss-Protection: 1; mode=blockAtl-Traceid: 56493e3118d37b45Report-To: {"group": "endpoint-1", "max_age": 600, "endpoints": [{"url": "https://subdomain.cloudfront.net"}], "include_subdomains": true}Nel: {"report_to": "endpoint-1", "max_age": 600, "include_subdomains": true, "failure_fraction": 0.001}Transfer-Encoding: chunked{"id":"343709","key":"MY_KEY-7","self":"https://domain.atlassian.net/rest/api/2/issue/343709"
I just resolved the issue.
(1) It's not json=jj
It must be data = jj
(2) Description must meet Atlassian Document requirements:
description": { "type": "doc", "version": 1, "content": [ { "type": "paragraph", "content": [ { "type": "text", "text": "description" } ] } ] },
It looks like you're new here. Sign in or register to get started.