UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21. Read more.
UPDATE! The community will be go into read-only on April 19, 8am Pacific in preparation for migration on April 21.Read more.
Admiral
Admiral
231 views

Cannot parse JSON in REST Activity

Jump to solution

Hi,

I'm using the rest activity to get the EasyVista ID of a user.

I get the JSON answer from the rest activity in flowdata/activity1/content:

{ "HREF": "https:\/\/easyvista-tst.test.com\/api\/v1\/50004\/employees?fields=employee_id\u0026search=e_mail:**PERSONAL INFORMATION REMOVED**", "record_count": "1", "total_record_count": "1", "records": [ { "HREF": "https:\/\/easyvista-tst.eca-vaud.intranet\/api\/v1\/50004\/employees\/237", "EMPLOYEE_ID": "237" } ] }

In the next activity I'm trying to get the employee_ID with the following (from NetIQ doc):

(function () { var returnJSON = ScriptVault.JSON.parse( flowdata.get('Activity1/content') ); var mgrID = returnJSON.EMPLOYEE_ID; return mgrID;}) ();

But the result is :

com.novell.soa.script.mozilla.javascript.Undefined@448641f8

(Not an error)

Any idea ?

Thanks

Sylvain

 

 

 

Labels (1)
0 Likes
1 Solution

Accepted Solutions
Knowledge Partner Knowledge Partner
Knowledge Partner

Formatting the JSON I find makes it easier to read.  So your response looks like:

{
   "HREF":"https:\/\/easyvista-tst.test.com\/api\/v1\/50004\/employees?fields=employee_id\u0026search=e_mail:**PERSONAL INFORMATION REMOVED**",
   "record_count":"1",
   "total_record_count":"1",
   "records":[
      {
         "HREF":"https:\/\/easyvista-tst.eca-vaud.intranet\/api\/v1\/50004\/employees\/237",
         "EMPLOYEE_ID":"237"
      }
   ]
}

 

So the EMPLOYEE_ID is a child of records.  So maybe in your function, the element:

var mgrID = returnJSON.EMPLOYEE_ID

might be better served as:

var mgrID = returnJSON.results[0].EMPLOYEE_ID

or somesuch.

View solution in original post

2 Replies
Knowledge Partner Knowledge Partner
Knowledge Partner

Formatting the JSON I find makes it easier to read.  So your response looks like:

{
   "HREF":"https:\/\/easyvista-tst.test.com\/api\/v1\/50004\/employees?fields=employee_id\u0026search=e_mail:**PERSONAL INFORMATION REMOVED**",
   "record_count":"1",
   "total_record_count":"1",
   "records":[
      {
         "HREF":"https:\/\/easyvista-tst.eca-vaud.intranet\/api\/v1\/50004\/employees\/237",
         "EMPLOYEE_ID":"237"
      }
   ]
}

 

So the EMPLOYEE_ID is a child of records.  So maybe in your function, the element:

var mgrID = returnJSON.EMPLOYEE_ID

might be better served as:

var mgrID = returnJSON.results[0].EMPLOYEE_ID

or somesuch.

View solution in original post

Admiral
Admiral
“Elementary, my dear Watson” !

It works fine, thanks a lot.

Sylvain
The opinions expressed above are the personal opinions of the authors, not of Micro Focus. By using this site, you accept the Terms of Use and Rules of Participation. Certain versions of content ("Material") accessible here may contain branding from Hewlett-Packard Company (now HP Inc.) and Hewlett Packard Enterprise Company. As of September 1, 2017, the Material is now offered by Micro Focus, a separately owned and operated company. Any reference to the HP and Hewlett Packard Enterprise/HPE marks is historical in nature, and the HP and Hewlett Packard Enterprise/HPE marks are the property of their respective owners.