How to get JSON data using AP.request?

Hey there,

In my function, I retrieve data as follows:

AP.request

    return new Promise((resolve, reject) => {
        window.AP.request({
            url: jiraRestApiUrl,
            type: 'GET',
            success: function (responseText) {
                resolve(JSON.parse(responseText));
            },
            error: function (xhr, statusText, errorThrown) {
                reject(arguments);
            }
        })
    });

Unfortunately when I add contentType: "application/json",
nothing changes - the data received is always text.

How can I get data as JSON without parsing ?

Thanks a lot for any help!
Regards
Mik

You can’t. AP.request will always return plain text that you will need to JSON.parse:

https://developer.atlassian.com/cloud/jira/platform/jsapi/request/

2 Likes

Thanks @remie