Forums

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

Creating a Jira Issue with a AJAX POST does not work

Max K
I'm New Here
I'm New Here
Those new to the Atlassian Community have posted less than three times. Give them a warm welcome!
July 2, 2018

Hey,

I've been trying to create an Issue in Jira from Confluence via an embedded javascript file for quite a while now, but it just does not seem to work. Currently the returned error is "415 Unsupported Media Type", which according to this site
should be fixed, by adding the correct ContentType, which I did, but which did not help

here is my javascript code


let req = {
    fields: {
        project: {
            "key": "ERM"
        },
        summary: "Test #00",
        description: "Test #00",
        dataType: 'json',
        issuetype: {
            "name": "Deliverable",
        },
        "Component/s": ["AIDA"],
        Project: {
            key: "ERM",
        },
        Vendor: {
            value: "NC",
        },
    }
};

function init() {
    $.ajaxSetup({
        crossDomain: true,
        contentType: 'application/xml; charset=utf-8',
        xhrFields: {
            withCredentials: true
        },
    });
    $.post("../../../jira/rest/api/2/issue/", JSON.stringify(req), processData);
};

function processData(data) {
    console.log(data);
};

Hopefully one of you is able to help me! Thanks in advance.

1 answer

0 votes
Josh Steckler
Rising Star
Rising Star
Rising Stars are recognized for providing high-quality answers to other users. Rising Stars receive a certificate of achievement and are on the path to becoming Community Leaders.
July 3, 2018

Your content type should be 'application/json' -- not xml.

While that version of Fisheye/Crucible referenced in your link may accept XML, Jira doesn't.

Suggest an answer

Log in or Sign up to answer