0

I am trying to create issue in project via curl, but it ends with 415 error which I don't know why as I am pasting only text there.

curl -D- -s -u email:api_key -X POST --data "{\"fields\":{\"project\":{\"key\": \"PROBLEM\"},\"summary\": \"REST ye merry gentlemen.\",\"description\": \"Creating of an issue using project keys and issue type names using the REST API\",\"issuetype\": {\"name\": \"Outage\"}}}" https://company.atlassian.net/rest/api/2/issue/ 

Output:

HTTP/2 415 
date: Tue, 27 Sep 2022 11:14:10 GMT
content-type: text/html;charset=UTF-8
server: globaledge-envoy
timing-allow-origin: *
x-arequestid: bbc0506d-8e7c-442f-a180-46632081b6a5
set-cookie: atlassian.xsrf.token=BAHL-ME69-JQ45-BS4O_929b97ddce3a4de2b40abbd3d2817ff133d29cee_lin; path=/; SameSite=None; Secure
x-aaccountid: 62b303db84d73c7201680c55
x-envoy-upstream-service-time: 56
expect-ct: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/atlassian-proxy", max-age=86400
strict-transport-security: max-age=63072000; preload
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
atl-traceid: b0b3324454c29763
report-to: {"endpoints": [{"url": "https://dz8aopenkvv6s.cloudfront.net"}], "group": "endpoint-1", "include_subdomains": true, "max_age": 600}
nel: {"failure_fraction": 0.001, "include_subdomains": true, "max_age": 600, "report_to": "endpoint-1"}
vary: Accept-Encoding

I don't understand why I am getting 415 message from Jira.

1 Answer 1

5
+50

HTTP 415 means Unsupported Media Type (https://developer.mozilla.org/en-US/docs/Web/HTTP/Status/415).

Basically, you have to tell JIRA you are sending a JSON. Just add:

-H 'Content-Type: application/json'

to your curl command. Also another note you may want to use rest/api/3/issue/ instead of rest/api/2/issue/

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

and if you got some error message like:

Operation value must be an Atlassian Document (see the Atlassian Document Format)

change your "description" field to something like this:

"description": {
    "type": "doc",
    "version": 1,
    "content": [
        {
            "type": "paragraph",
            "content": [
                {
                    "type": "text",
                    "text": "Creating of an issue using project keys and issue type names using the REST API"
                }
            ]
        }
    ]
}

For example

curl -i -u [email protected]:xxxxxx  -H 'Content-Type: application/json' -XPOST --data '{"fields": {"project": {"key": "RW"}, "summary": "REST ye merry gentlemen.", "description": {"type": "doc", "version": 1, "content": [{"type": "paragraph", "content": [{"type": "text", "text": "Creating of an issue using project keys and issue type names using the REST API"} ] } ] }, "issuetype": {"name": "Task"} } }' https://s50600822.atlassian.net/rest/api/3/issue

{"id":"10013","key":"RW-6","self":"https://s50600822.atlassian.net/rest/api/3/issue/10013"}
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.