What is the use of scripted rest api over Rest message?

KM SN
Tera Expert

When we can get the data , post the data, update the data using REST message and what is the need of scripted rest api.

Can i get some insights and use cases on it?

2 ACCEPTED SOLUTIONS

Sid_Takali
Kilo Patron
Kilo Patron

Hi @KM SN 

"Rest Message" in ServiceNow is designed for sending updates from ServiceNow to an external system, provided the external system supports REST. It enables you to share data with external applications.
1)Let's say your company uses a weather service to get current weather data, and you want to integrate this data into your ServiceNow incident records.
Example: You create a REST Message named "WeatherAPI" that sends an HTTP GET request to the weather service's API endpoint for retrieving weather data based on a given location. The response from the weather service contains the current weather conditions. You can use this REST Message in a business rule or script to automatically update the weather information in your incident records based on their location.

On the other hand, a "Scripted REST API" allows for inbound updates from an external system. If you need to receive data in ServiceNow and perform custom processing like validations, especially when the standard REST APIs do not support your requirements, you can create a scripted REST web service. This allows you to process incoming requests from external systems and perform custom actions.
1)Suppose you want to provide external partners with access to a list of the latest product prices stored in your ServiceNow instance.
Example-You create a Scripted REST API named "ProductPricing" with an endpoint "/getLatestPrices." In the script for this API, you write code that queries the latest product prices from your database and returns them in a structured format, like JSON. External systems can now make requests to this endpoint to get up-to-date product prices.
Please mark it as solution proposed and helpful if it serves your purpose.

View solution in original post

Amit Pandey
Kilo Sage

Hi @KM SN 

 

REST Message is used for sending outbound updates to an external system from Service Now. If a third party application supports REST then you can send data from Service Now using the rest message.

 

Scripted REST API on the other hand enables inbound updates from an external system. If an external system needs to send data to Service Now and if you need to process custom changes(validations etc) which are not supported by OOB REST API's then you can write a scripted REST web service to process inbound requests from external systems.

 

Please mark my answer helpful and correct.

 

Regards,

Amit

View solution in original post

3 REPLIES 3

Sid_Takali
Kilo Patron
Kilo Patron

Hi @KM SN 

"Rest Message" in ServiceNow is designed for sending updates from ServiceNow to an external system, provided the external system supports REST. It enables you to share data with external applications.
1)Let's say your company uses a weather service to get current weather data, and you want to integrate this data into your ServiceNow incident records.
Example: You create a REST Message named "WeatherAPI" that sends an HTTP GET request to the weather service's API endpoint for retrieving weather data based on a given location. The response from the weather service contains the current weather conditions. You can use this REST Message in a business rule or script to automatically update the weather information in your incident records based on their location.

On the other hand, a "Scripted REST API" allows for inbound updates from an external system. If you need to receive data in ServiceNow and perform custom processing like validations, especially when the standard REST APIs do not support your requirements, you can create a scripted REST web service. This allows you to process incoming requests from external systems and perform custom actions.
1)Suppose you want to provide external partners with access to a list of the latest product prices stored in your ServiceNow instance.
Example-You create a Scripted REST API named "ProductPricing" with an endpoint "/getLatestPrices." In the script for this API, you write code that queries the latest product prices from your database and returns them in a structured format, like JSON. External systems can now make requests to this endpoint to get up-to-date product prices.
Please mark it as solution proposed and helpful if it serves your purpose.

Amit Pandey
Kilo Sage

Hi @KM SN 

 

REST Message is used for sending outbound updates to an external system from Service Now. If a third party application supports REST then you can send data from Service Now using the rest message.

 

Scripted REST API on the other hand enables inbound updates from an external system. If an external system needs to send data to Service Now and if you need to process custom changes(validations etc) which are not supported by OOB REST API's then you can write a scripted REST web service to process inbound requests from external systems.

 

Please mark my answer helpful and correct.

 

Regards,

Amit

OlaN
Giga Sage
Giga Sage

Hi,

There is an excellent videoseries on Youtube you can watch, it should answer all your questions around scripted REST.