Unable to retrieve complete information of Requirement Document through Rest API Call

I am trying to fetch the requirement document information (UDF) by launching below rest api

API : hostname:port/.../3008

I get following response on launching rest api on chrome browser in a new tab where octane is already running. 

Browser Response : 

"type":"requirement_document",
"id":"3008",
"name":"Addition Screen",
"logical_name":"px8zomy5pe88qs874g8p3o9gy",
"workspace_id":3001,
"parent":{
"type":"requirement",
"id":"3003",
"name":"Screens",
"subtype":"requirement_folder"
},
"type_udf":{
"type":"list_node",
"id":"3w51el9nmrljgfolxw53emx0k",
"logical_name":"3w51el9nmrljgfolxw53emx0k",
"activity_level":0,
"index":2,
"name":"Screen"
}
}

But I get below response when I calling the same api from node.js

Program : 

var request = require('request'),
username = "username",
password = "password",
auth = "Basic " new Buffer.from(username ":" password).toString("base64"),
url = "">hostname:port/.../3008

request(
{
url : url,
headers : {
"Authorization" : auth,
"ALM_OCTANE_TECH_PREVIEW" : true,
"HPE_REST_API_TECH_PREVIEW" : true
}
},
function (error, response, body) {
console.log("response.statusCode " , response.statusCode);
if (!error && response.statusCode == 200) {
console.log(JSON.parse(body));
}
}
);

NodeJS Response : 

{
type: 'requirement_document',
id: '3008',
name: 'Addition Screen',
parent: { type: 'requirement_folder', id: '3003' },
type_udf: { type: 'list_node', id: '3w51el9nmrljgfolxw53emx0k' }
}

I want name variable of  "type_udf" (highlighted in browser response) to be shown in nodejs response. Kindly let me know how this can be achieved.

 

Thanks

Akshatha

  • Hi

    When you use the call through your bowser you are using the context of the UI.  The UI includes headers that activate the private REST API.  One of the features of the private REST API is the ability to get related field data in one call.  So your type_udf is a related list and therefore it gets all the information.

    However - with your example from Node.js you are using the protected API (or even public) which does not have that ability.

    We do not support the use of the private API and the suggested method is to make two calls; 1 to get the document and the second to get the related list_node information.

    By the way - did you know that we have a Node.js SDK that removes a lot of the backend code that you have here?  You can find it here: https://www.npmjs.com/package/@microfocus/alm-octane-js-rest-sdk