API

Divyabharathi C
Tera Contributor

Hello all,

I need a steps to do the below requirements.

1. Hit an API to get updates.
2. Script needs to get scheduled daily to call API
3. Parse response and create incident based on "Hitcount" value in response.

1 ACCEPTED SOLUTION

Vishnu kumar R
Tera Guru

Hi @Divyabharathi C,

 

You can achieve your requirements by creating the below records.

1. Create a scheduled Job with occurrence as Daily at the non business hours, So it will handle huge load.

2. Create a rest message using the API and test.

3. Copy the script by clicking on "Preview Script Usage" related link.

4. Use the script in your scheduled job.

5. Parse the response that you receive from triggering API, In your case "Hitcount".

Sample parse script:

/*Response
{
"Name": "123",
"Hitcount": 10
}
*/

 var responseBody = response.getBody();
 var msg = JSON.parse(responseBody);
 gs.info(msg.Hitcount);
while(var i < Hitcount)
{
//Script to create incident based on your reqirement.
i++
}

Use the sample script based on your requirement.

 

Kindly mark this as Helpful if it solves your query.

View solution in original post

1 REPLY 1

Vishnu kumar R
Tera Guru

Hi @Divyabharathi C,

 

You can achieve your requirements by creating the below records.

1. Create a scheduled Job with occurrence as Daily at the non business hours, So it will handle huge load.

2. Create a rest message using the API and test.

3. Copy the script by clicking on "Preview Script Usage" related link.

4. Use the script in your scheduled job.

5. Parse the response that you receive from triggering API, In your case "Hitcount".

Sample parse script:

/*Response
{
"Name": "123",
"Hitcount": 10
}
*/

 var responseBody = response.getBody();
 var msg = JSON.parse(responseBody);
 gs.info(msg.Hitcount);
while(var i < Hitcount)
{
//Script to create incident based on your reqirement.
i++
}

Use the sample script based on your requirement.

 

Kindly mark this as Helpful if it solves your query.