REST API best practices
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2015 07:40 AM
Hi All,
I have a requirement to setup inbound REST API, so the third party system can consume our REST API's to create/update the incident tickets in our system.
At the same time we do not want them to send any data that is not compliance with the our data. From their end they just invoke the API, but we do want to validate the data before it gets updated into our tables.
Please let us know best practices or steps that can be taken care to come over this situation.
Thanks.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2015 08:01 AM
Use 'before insert' business rules to check inputs before the record is saved to the database. In a business rule, you can do any kind of data validation.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-24-2015 08:17 AM
Hi Slava,
I dont want to write a global business rule which could always be invoked for any other systems trying to create the ticket.
Also, it is a REST API which expects the response instantly. Not sure where to start the validation in order to send it back even before it tries to insert into the table.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-27-2015 08:04 AM
Business rules are meant to be used for data validation:
You do not a global business rule for this. Global rules apply to all tables whereas you only need to define a rule for Incident table.
Blog: https://sys.properties | Telegram: https://t.me/sys_properties | LinkedIn: https://www.linkedin.com/in/slava-savitsky/
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
‎07-31-2015 02:16 PM
Hi Ramji, the best practice here would be to use a web service import set which can be invoked via the REST API but would not affect when inserts/updates are made to the target tables when updated outside of the import set.
Import sets allow you to insert data into a staging table and then define field mappings to map the data to the target table. It also supports an on-start script where you could put the validation logic. Please refer to these links for more information on Import sets as well as the REST Import Set API.
http://wiki.servicenow.com/index.php?title=Import_Sets
http://wiki.servicenow.com/index.php?title=Import_Set_API