Skip to main content

Say i have something like this as the ResponseAPI

 

{

"data": {

"id": 2,

"email": "janet.weaver@reqres.in",

"first_name": "Janet",

"last_name": "Weaver",

"avatar": "https://reqres.in/img/faces/2-image.jpgquot;

},

}

 

using JSON object manager package i could get the data just fine but have a problem taking the email,id,etc. is there a way to do it with JSON object manager package? or do i need to have anotehr package/ use string manipulation to do it?

You can try JSON Get Node Value, just put data.id, data.email to get id and email respectively.


hi @ishan mahajan​ 

 

sorry for late reply, thanks for answering it works and i have anotherquestion what if the data looks like this? and i wanted to take each email from the data? i tried using the JSON package and tried to use the Get Node List and but everytime i wanted to show it on a message box "$ListL1]$" it says that "Unsupported node type provided in the session"

 

{

"data": o

{

"id": 7,

"email": "michael.lawson@reqres.in",

"first_name": "Michael",

"last_name": "Lawson",

"avatar": "https://reqres.in/img/faces/7-image.jpgquot;

},

{

"id": 8,

"email": "lindsay.ferguson@reqres.in",

"first_name": "Lindsay",

"last_name": "Ferguson",

"avatar": "https://reqres.in/img/faces/8-image.jpgquot;

},

{

"id": 9,

"email": "tobias.funke@reqres.in",

"first_name": "Tobias",

"last_name": "Funke",

"avatar": "https://reqres.in/img/faces/9-image.jpgquot;

},

],

}

 


Hi @David Jansen​ ,

 

You can try using this JsonPath:

$..email

imageThen using String Operations, you can split the items and retrieve the emails one by one.

 

Kind Regards,

Ashwin A.K


Hi David,

 

you can use what Ashwin has suggested, this would return you a String i guess, you may have to put some string operations to get email values or you can take the output of Get Node list(for Data node) in a list, convert that list to string and start a new JSNO session with this text.

 

and use Get node value of 'email' to get value of email, you will have to resart JSON session multiple times,

 

image


hi @Ashwin A.K​  & @ishan mahajan​ 

 

i already tried and both way works well. but i notice that the REST web service in Automation Anywhere is a bit old since most the API doesn't requires us to do the authentication with id and password instead we will get API Key.

 

Is there a way using REST web services in AA to get an API using the API Key as the authentication method? if there is what authentication method should be selected?


Hi @David Jansen​ ,

 

Depends on the API Specification.

Usually the API Key is added as a Header like so:

 

imageIf its OAuth 2.0, then you might have to add additional Headers/Parameters like ClientId, ClientSecret, Domain etc just to name a few.

 

As for refining the data outputted from the Json Package, I use String: Replace toggled to regex like so:

 

>\]\<\"]

 

imageI bet there is an easier way to go about refining this, but I'm too lazy to think of anything creative right now.

 

Kind Regards,

Ashwin A.K


hi @Ashwin A.K​ 

 

sorry for the late reply and thanks for helping me


Reply