Extract value from JSON field

#1

Hello,

I am trying to authenticate an API call where I send a JSON POST and get a response. The response.body contains the value of “session=XXXXX”. I am looking to determine how to extract the XXXX out of the response. Then I, of course, will use that for the subsequent GET or POST to follow. Is there some simple expression to retrieve the value after a special character like the “=” in this case? Or am I totally missing that there is already a node to generate the session ID with ease?

Thank you,

#2

I’d recommend using a function node to split the string and save the session ID into another payload field.

payload.data.sessionId = payload.data.body.split('=')[1];

Now you can use data.sessionId in any following nodes.

#3

Thanks Brandon. I started looking at functions late last night but hadn’t figure it out yet. I just tried your recommendation and it works great extracting the session id. Thank you very much.