You should really encourage the entity responsible for the API to provide you with a parsable response, like JSON. This is really a nasty hack which can easily break in the future.
Your given solution is working for me but here I have some more text in the next line before the space which one I don’t want to take in my variable value.
So could you please let me know how can I add 2 split in single function or split text.
Response Body:
Job Id : 70c33082-326f-4276-88ca-04dcc046ef55
Total Number of Records: 2
Total Number of Successful Records: 0
Total Number of Failure Records: 2
Total Number of Blank Records: 0
My Script:
var SearchHelp = pm.response.text().split(" ")[3];
Getting ‘SearchHelp’ Value:
70c33082-326f-4276-88ca-04dcc046ef55
Total
and I need only 70c33082-326f-4276-88ca-04dcc046ef55 value in my SearchHelp variable.
It seems like you have a different response to the original question and the different pieces of data are on new lines, something like this might help you:
let splitResponse = pm.response.text().split("\n")
pm.environment.set("SearchHelp", splitResponse[0].split(" ")[3])
It looks hacky and it felt hacky even writing this though
You should really encourage the entity responsible for the API to provide you with a parsable response, like JSON. This is really a nasty hack which can easily break in the future.
If that’s a JSON response, you would just need to do this:
console.log(pm.response.json().Token[0])
The original question was talking about a response that was text across multiple lines so that solution wouldn’t really work for your response. As it’s JSON, you can just retrieve this in the normal way.