Hello,
I'm trying to get around the AP.request method from the Javascript API.
Based on the Product cookbook, I've built the following but it returns an error 415:
function dummy() {
const bodyData = {
"fields": {
"customfield_10037": "123456"
}
}
AP.request({
url: '/rest/api/2/issue/ABC-2',
type: 'PUT',
data: JSON.stringify(bodyData),
success: function(response) {
// convert the string response to JSON
response = JSON.parse(response);
// dump out the response to the console
console.log(response);
},
error: function() {
console.log(arguments);
},
// inform the server what type of data is in the body of the HTTP POST
contentType: "application/json"
});
}
I've tried to search for similar cases and there are a few, but most point to the contentType being the issue. However mine is already set to what is described in the cookbook (standard json type). The scopes are set to "PROJECT_ADMIN".
Does anyone have an idea about what may be wrong here? No response is returned besides the error code, here are the response headers:
atl-traceid: 6fb8f8221a0d6b18
content-type: text/html;charset=UTF-8
date: Mon, 28 Sep 2020 23:23:55 GMT
expect-ct: report-uri="https://web-security-reports.services.atlassian.com/expect-ct-report/global-proxy", enforce, max-age=86400
micros-issuer: micros/edge-authenticator
server: AtlassianProxy/1.15.8.1
status: 415
strict-transport-security: max-age=315360000; includeSubDomains; preload
timing-allow-origin: *
x-aaccountid: xyz
x-arequestid: abc
x-content-type-options: nosniff
x-xss-protection: 1; mode=block
Fixed using API V3.
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.