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

Next challenges

Recent achievements

  • Global
  • Personal

Recognition

  • Give kudos
  • Received
  • Given

Leaderboard

  • Global

Trophy case

Kudos (beta program)

Kudos logo

You've been invited into the Kudos (beta program) private group. Chat with others in the program, or give feedback to Atlassian.

View group

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

Fields not available thru API

I am using Google Scripts to try and read worklog entries.  I can get to most of the issues fields but get an undefined error when I try to access worklog related fields.  I have time tracking turned on and I have the permissions for time entry set.  What am I doing wrong?

 

var fetchArgs = {
contentType: "application/json",
headers: {"Authorization":"Basic "+encCred},
muteHttpExceptions : true
};

var jql = "?jql= issuetype=task order by created DESC";

Logger.log("jql = " + jql);
var httpResponse = UrlFetchApp.fetch(baseURL + jql, fetchArgs);
Logger.log("httpResponse = " + httpResponse);

if (httpResponse) {

var rspns = httpResponse.getResponseCode();
switch(rspns){
case 200:
var data = JSON.parse(httpResponse.getContentText());
var issuessss = [];

for(var id in data["issues"])
{

// Check the data is valid and the Jira fields exist
if(data["issues"][id] && data["issues"][id].fields) {


var status = data["issues"][id].fields.timespent;
Logger.log("timeSpent = " + timeSpent);
var worklogdate = data["issues"][id].fields.worklogdate;
Logger.log("worklogdate = " + worklogdate);

var type = data["issues"][id].fields.issuetype.name;
var reporter = data["issues"][id].fields.reporter.displayName;
var summary = data["issues"][id].fields.summary;
Logger.log("type = " + type + "-" + reporter + " " + summary);

issuessss.push([type,reporter,summary]);// adding each issue data to 2D array
}
}

1 answer

Hi @Sigmund VanDamme  -- Welcome to the Atlassian Community!

One way to check the names of the fields, and what is supported, is to make a call to the REST API and then parse the JSON to see what is there.  So pick a Jira issue you know has the data you want and use that issue.

Here is the how-to for that method:

https://support.atlassian.com/jira-software-cloud/docs/find-the-smart-value-for-a-field/

Best regards,

Bill

Suggest an answer

Log in or Sign up to answer
DEPLOYMENT TYPE
CLOUD
PRODUCT PLAN
FREE
PERMISSIONS LEVEL
Site Admin
TAGS
Community showcase
Posted in Jira Software

Presenting the "Best of 2020" Jira Software roundup!

Catch up with Atlassian Product Managers in our 2020 Demo Den round-up! From Advanced Roadmaps to Code in Jira to Next-Gen Workflows, check out the videos below to help up-level your work in the new ...

7,138 views 8 28
Join discussion

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