function makePostRequest() {
var data = { "fields": { "project":{ "key": "****" }, "priority": { "name": "Medium" }, "duedate": "test", "summary": "summary", "description": "description", "issuetype":{ "name": "Task" } }};
const url = "https://*****.atlassian.net/rest/api/latest/issue"; const response = UrlFetchApp.fetch(url, { "method": "POST", "headers": { "X-Atlassian-Token" : "no-check", "Authorization": "Bearer ************", "Accept": "application/json", "Content-Type": "application/json" }, "muteHttpExceptions": true, "followRedirects": true, "validateHttpsCertificates": true, "contentType": "application/json", "payload": JSON.stringify( { "fields": { "project":{ "key": "INFOSEC" }, "Priority": { "name": "Medium" }, "Description": "description", "issuetype":{ "name": "Task" } } } ) });
Logger.log("Response code is %s", response.getResponseCode()); Logger.log(response.getContentText());}
Error: {"errorMessages":[],"errors":{"Priority":"Field 'Priority' cannot be set. It is not on the appropriate screen, or unknown.","Description":"Field 'Description' cannot be set. It is not on the appropriate screen, or unknown."}}
I have checked the screens and they are correctly configured and I have admin and developer access to all of them, so I assume it's an issue with my request.
Yes I think the "var data = ... " is in the correct format ... but you are posting a different payload where Priority and Description field id are capitalized.
Try with "payload": JSON.stringIfy( data )
You must be a registered user to add a comment. If you've already registered, sign in. Otherwise, register and sign in.