简体   繁体   中英

How can I query the Rally “Project” field in custom API with Javascript?

I am trying to determine a way to only display defects for a specific project in my Javascript using Rally API. I tried adding https://rally1.rallydev.com/slm/webservice/v2.0/project/84123456320d/defect?query=(Resolution%20!=%20%22None%22)&fetch=FormattedID,Name,Resolution,c_ResolutionSummary,Project,Description&pagesize=2000 "(my custom query for defects) but this doesn't work for me, when I test this in the browser I get a "Failure to parse" error even though I'm sure that's the correct project #. (This works fine without adding the project/number part and will return a huge number of defects).

So my alternative right now is to simply query the "Project" field in a Rally defect and check to see if it's for a specific project under certain conditions. To do this I am simply using the "Project" field like above.

The problem is that when I actually run a console.log on this var:

var project = data["QueryResult"]["Results"][i]["Project"];

I am getting a long span result that contains a whole bunch of information and won't work on a .includes.

How can I simply query the name of the project and get that back as a var? So if our project as simply "Happy Team" I would expect console.log on that var would only return "Happy Team".

Request:

  "https://rally1.rallydev.com/slm/webservice/v2.0/defect?query=(Resolution%20!=%20%22None%22)&fetch=FormattedID,Name,Resolution,c_ResolutionSummary,Project,Description&pagesize=2000",

Var:

var project = data["QueryResult"]["Results"][i]["Project"];

Call:

console.log(project);

Output:

{ _rallyAPIMajor: '2',
  _rallyAPIMinor: '0',
  _ref: 'https://rally1.rallydev.com/slm/webservice/v2.0/project/123456789',
  _refObjectUUID: 'redacted',
  _objectVersion: '17',
  _refObjectName: 'E_Team',
  Description: '<span style="color: rgb(51, 51, 51); font-family: Arial, sans-serif; font-size: 14px; white-space: pre-wrap; background-color: rgb(255, 255, 255);">This is a description changed from original (redacted).</span>',

Project is returned as an object. You should be able to get the name by just drilling down one more level:

var projectName = data.QueryResult.Results[i].Project._refObjectName;

The _refObjectName is always returned on objects regardless of your fetch parameters. You could also add Name to your fetch list and then use the Name field returned on Project as well.

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM