Need advice on implementing a REST integration with an application to respond with table data

PratyushaBodepu
Mega Guru

Hi All, 

 

There is a requirement where we need to integrate with a 3rd party application where we need to send them a specific custom table's data, the current number of records in it is about 50k.

 

I'm a beginner when it comes to OOB integration implementations.

Please suggest a way forward to implement this functionality.

 

Looking forward to your expert advice! 🙂

 

Best Regards,

Pratyusha

1 ACCEPTED SOLUTION

Ratnakar7
Mega Sage
Mega Sage

Hi @PratyushaBodepu ,

 

You can follow these steps:

  1. Identify the custom table in ServiceNow that contains the data you want to send to the 3rd party application. Make sure the table has the necessary fields and data that need to be included in the integration.

  2. Determine the endpoint or URL provided by the 3rd party application where you will be sending the data. Understand the expected data format or any authentication requirements specified by the 3rd party application.

  3. Create a scripted REST API in ServiceNow to fetch the data from the custom table and format it according to the requirements of the 3rd party application.

    • If you prefer to use a scripted REST API, you can define the endpoint, HTTP methods, and authentication requirements directly in the ServiceNow platform. You can write JavaScript code in the scripted REST API to query the custom table and format the data accordingly.

  4. Write the necessary logic in the REST API script or scripted REST API to query the custom table using a GlideRecord. Apply any filters or conditions if required to fetch the specific data you need. Iterate through the records and extract the necessary fields.

  5. Format the data retrieved from the custom table into the desired format required by the 3rd party application. This could be JSON, XML, or any other format specified by the 3rd party application.

  6. Send the formatted data to the endpoint provided by the 3rd party application using an HTTP request. You can use the sn_ws.RESTMessageV2 API in ServiceNow to send the request. Set the appropriate headers, payload, and authentication details as required by the 3rd party application.

  7. Handle the response from the 3rd party application if necessary. You may need to parse the response and take appropriate actions based on the integration requirements.

  8. Test the integration thoroughly to ensure that the data is being fetched from the custom table correctly, formatted properly, and sent to the 3rd party application without any issues. Monitor the integration for any errors or exceptions and handle them appropriately.

It's important to consider factors like data volume (50k records in your case) and potential performance implications. You may need to implement pagination or consider batch processing if the data size is large.

 

If you're new to integration development in ServiceNow, it can be helpful to refer to the below ServiceNow documentation: 
Scripted REST API examples 

Scripting outbound REST 

Configure pagination size 

https://www.servicenow.com/community/developer-forum/need-integration-rest-inbound-and-outbound-best...

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.

 

Thank you!

Ratnakar

View solution in original post

2 REPLIES 2

Ratnakar7
Mega Sage
Mega Sage

Hi @PratyushaBodepu ,

 

You can follow these steps:

  1. Identify the custom table in ServiceNow that contains the data you want to send to the 3rd party application. Make sure the table has the necessary fields and data that need to be included in the integration.

  2. Determine the endpoint or URL provided by the 3rd party application where you will be sending the data. Understand the expected data format or any authentication requirements specified by the 3rd party application.

  3. Create a scripted REST API in ServiceNow to fetch the data from the custom table and format it according to the requirements of the 3rd party application.

    • If you prefer to use a scripted REST API, you can define the endpoint, HTTP methods, and authentication requirements directly in the ServiceNow platform. You can write JavaScript code in the scripted REST API to query the custom table and format the data accordingly.

  4. Write the necessary logic in the REST API script or scripted REST API to query the custom table using a GlideRecord. Apply any filters or conditions if required to fetch the specific data you need. Iterate through the records and extract the necessary fields.

  5. Format the data retrieved from the custom table into the desired format required by the 3rd party application. This could be JSON, XML, or any other format specified by the 3rd party application.

  6. Send the formatted data to the endpoint provided by the 3rd party application using an HTTP request. You can use the sn_ws.RESTMessageV2 API in ServiceNow to send the request. Set the appropriate headers, payload, and authentication details as required by the 3rd party application.

  7. Handle the response from the 3rd party application if necessary. You may need to parse the response and take appropriate actions based on the integration requirements.

  8. Test the integration thoroughly to ensure that the data is being fetched from the custom table correctly, formatted properly, and sent to the 3rd party application without any issues. Monitor the integration for any errors or exceptions and handle them appropriately.

It's important to consider factors like data volume (50k records in your case) and potential performance implications. You may need to implement pagination or consider batch processing if the data size is large.

 

If you're new to integration development in ServiceNow, it can be helpful to refer to the below ServiceNow documentation: 
Scripted REST API examples 

Scripting outbound REST 

Configure pagination size 

https://www.servicenow.com/community/developer-forum/need-integration-rest-inbound-and-outbound-best...

 

If my response was helpful in resolving the issue, please consider accepting it as a solution by clicking on the Accept solution button and giving it a thumbs up 👍. This will benefit others who may have a similar question in the future.

 

Thank you!

Ratnakar

Thank you @Ratnakar7 for such a detailed response! 😀

 

We haven't decided on how we'll proceed, to push the data or let them pick the data if we give them an endpoint. I initially created a Scripted REST API that will give the formatted data required that can be picked up by a GET request.

 

I'll have to explore more into how the data in turn can be sent from ServiceNow using Scripted REST API.