- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-28-2019 11:58 PM
Hi,
I have required/mandatory fields in Customer_contact table. When i try to create (POST) a contact via REST API it is creating record with status 201. But i have a required field account in customer_contacts table.
Please refer below image
Below is the contact which i have created via REST API.
Below image is the response for contact creation.
My question is, Why error not Shown when i try to post a contact via REST API, though a required field is not sent in request payload.
Solved! Go to Solution.
- Labels:
-
Personal Developer Instance

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-01-2019 06:43 AM
glad it worked .
kindly mark my answer as correct and close this thread
if you have further question , kindly open new thread .
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2019 12:14 AM
Hi Priya,
create data policy for this and have that field as mandatory;
so when somebody sends POST and no value in that field then it would throw an error
in left navigation type data policies; create new
give your table name and in data policy rule make your field as mandatory; for example I have used incident table and description as mandatory
then create data policy rules for this and make description as mandatory
Mark ✅ Correct if this solves your issue and also mark 👍 Helpful if you find my response worthy based on the impact.
Thanks
Ankur
Ankur
✨ Certified Technical Architect || ✨ 9x ServiceNow MVP || ✨ ServiceNow Community Leader
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2019 05:18 AM
Hi Ankur,
I tried creating data policies and added the field as mandatory. Now when try with API (without passing value for account) i am getting 403 error with data policy Exception message.
FYI: we are simulating the CRM behaviour in our integration.
#1. My question is,why we are facing different behaviour for same field in CRM UI and via REST API.It should be same but why this is differing?.
Because we need to show the field behaviors same as in CRM UI in our integration too.
#2. Adding field to data policy, is this the only way to throw error messages for validations via REST API?
#3.Is #1(different behaviour) is expected,then for what are all the fields in what are all the tables these behaviors differs happens? Please list it will be very helpful.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-29-2019 12:14 AM
Let me explain the working of above API.
The post request you are making is same as you are writing a GlideRecord() on the table and inserting a new record. There it will not check for any mandatory record (Just as you can edit any field in particular record from list view even if other mandatory fields are empty).
You should have validation at server side (Either Business Rule or Data Policy) for such cases.
But for your use case, I would recommend you to create a import set table and transform Map. Then have post REST API on import set table. This is best practice also as we should not directly post data into SNOW tables from Web services.
Here it will give you flexibility to write script for data validation and abort record insertion from script.
Hope this helped.
Let me know for any query.
Thanks,
Ali
Thank you,
Ali
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
11-28-2024 02:06 AM
Hi Ahmmed,
I am trying to do the same thing. Loading the data to import set table and then from import set to incident table. But where i can apply the mandatory validation from rest api to import set table.
I have written a POST method.
Thanks,
Diksha