How to write external JSON code ServiceNow REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-08-2022 08:38 AM
Hi There
Can anyone please help on how we need to write the below json code into REST Messages in ServiceNow under HTTP Methods-->Variable substitutions. When I run the below code in POSTMAN with the required headers we re getting the success response , but we are not sure how do we test this code in ServiceNow under REST Messages using HTTP Methods.

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 08:10 PM
Following things needs to be consider -
1. In rest api script - print request ( what is receiving )
2. In rest api script - try to decompose the request object and based on the structure of request object you have to write code accordingly.
3. Based on your code you will get object properties and their values.
Hope this can help you to get the request data.
You will find many articles to read JSON formatted data
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 09:39 PM
@Hemalatha1 Follow below steps
Update the request body in HTTP methods as follows:
3. Update the Test value field to just snCategory from "name":"snCategory" as in image below:
4. Click on Test related link
Please mark as correct answer if this solves your issue.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-14-2022 09:26 PM
@Hemalatha1 Did you try this? Please try if not already done.
ServiceNow Community Rising Star, Class of 2023
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
12-13-2022 10:42 PM
Hi @Hemalatha1 ,
ServiceNow provided the documentation for this refer below. Let us know if you face any difficulty/doubt.
ServiceNow Community MVP 2024.
Thanks,
Pavankumar