Skip to main content
Question

Need to fetch job id from http request output


Forum|alt.badge.img+6

I am using http request in workflow which is in running in loop to run vm level backup. as an output it returns output for each http request as show below 

[{ "taskId":250501,"jobIds":[ "21035126" ] },

{ "taskId":250502,"jobIds":[ "21035127" ] 

 

I want to fetch the jobids from this and add it is list. How can this be achieved.

2 replies

Forum|alt.badge.img+13
  • Vaulter
  • 166 replies
  • November 1, 2023

Hi @Rahul Nair,

 

You can use a ‘Script’ activity (which can be found under the Utilities section) to parse the string for you and extract the Job ID.  The Script activity will allow you to leverage either Java or JavaScript code to do this. 

 

You can leverage Java methods such as trim / split to isolate the job ID from the full output of your HttpClient activity.  There are many online resources (such as w3schools / stackoverflow) that have good examples to follow if you’re unfamiliar.  Have the script ‘return’ that value, so that the job ID is what’s contained in this Script activity’s output.

 

Once your Script activity is returning the Job ID, you can feed that output into an AddToList activity.

 

-Brian Bruno

 

 


Forum|alt.badge.img+1

Hello Rahul,

 

in addition to Brian answer - which is perfect - you can also change the response to XML instead of JSON and use XPath - it’s way easier and using standard activities. 

Let us know.

Mattia P


Reply


Cookie policy

We use cookies to enhance and personalize your experience. If you accept you agree to our full cookie policy. Learn more about our cookies.

 
Cookie settings