Create
cancel
Showing results for 
Search instead for 
Did you mean: 
Sign up Log in

It's not the same without you

Join the community to find out what other Atlassian users are discussing, debating and creating.

Atlassian Community Hero Image Collage

What is wrong with this Google Script RestAPI request?

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.

1 answer

0 votes

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 )

Suggest an answer

Log in or Sign up to answer
TAGS
Community showcase
Published in Jira

⏰ Day in the life of a Jira Admin!

Hello Community! We thoroughly enjoyed this just-for-fun conversation in the Jira Admin Group about what it's like to be a Jira Admin. For #JiraJuly, our talented designers created these graphics t...

934 views 2 22
Read article

Community Events

Connect with like-minded Atlassian users at free events near you!

Find an event

Connect with like-minded Atlassian users at free events near you!

Unfortunately there are no Community Events near you at the moment.

Host an event

You're one step closer to meeting fellow Atlassian users at your local event. Learn more about Community Events

Events near you