Table REST API VS Scripted REST API

David Cross
Tera Expert

Please help here,

 

when to use what, 

Can you please simplify me which API to use when with a real time scenario.

 

Ex :- if i have to insert data (POST) into a table, Now here duplicate values should not get inserted but updated. Which API will i use here..

1 ACCEPTED SOLUTION

Slava Savitsky
Giga Sage

With Table REST API, you can insert records directly into a table using POST and update records using PUT or PATCH methods. For updates, you need to supply the sys_id of the record you are going to update.

 

In many cases, however, it is not desirable to write to the target table directly. For example, if you need to validate or transform the data first. In this case, you can use Import Set REST API to write data to an Import Set table and trigger a Transform Map.

 

Finally, if none of the available REST APIs cover your use case, you can build your own Scripted REST API. For example, if you need to do some complex processing of your data and write different parts of it into different tables or trigger some further server-side APIs.

View solution in original post

4 REPLIES 4

Slava Savitsky
Giga Sage

With Table REST API, you can insert records directly into a table using POST and update records using PUT or PATCH methods. For updates, you need to supply the sys_id of the record you are going to update.

 

In many cases, however, it is not desirable to write to the target table directly. For example, if you need to validate or transform the data first. In this case, you can use Import Set REST API to write data to an Import Set table and trigger a Transform Map.

 

Finally, if none of the available REST APIs cover your use case, you can build your own Scripted REST API. For example, if you need to do some complex processing of your data and write different parts of it into different tables or trigger some further server-side APIs.

Thank You @Slava Savitsky , Your comment is very helpful.

SK Chand Basha
Giga Sage

Hi @David Cross 

 

I agree with the @Slava Savitsky 

 

If you wants to know more about how scripted rested API'S work i'm sharing a resource below 

 

https://youtu.be/ulKSAZsxFlw?si=b5kH_K0jT1iJ8-CQ

 

Mark it Helpful and Accept Solution!! If this helps you to understand.

This series delves into Scripted REST APIs and how to create a web service in ServiceNow to permit external clients/applications access to data in your ServiceNow instance. Scripts in this series are located in my GitHub repo: https://github.com/Jay-Cool/Vehicles-API-Files Further learning: - ...

thank you @SK Chand Basha