Trying to create a RITM using scripted REST API
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 04:05 AM
Hello all,
I am trying to create a requested item, from the scripted REST API.
So, for this, I have created a Scripted REST API and I created a resource, with POST method and written a script.
After that, when I clicked on Explore REST API related link and tested it, the record is not getting created in RITM table and just giving 200 - Success message but not 201 message.
Can someone help me whats wrong here?
response.setBody(ar); ------> this line of code is not captured in the screen shot, but this is there.
REST API Explorer:
Note: I am these in the Query parameters:
customer Application Services
Short description Test 123
Please help
Regards,
Pallavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 05:42 AM
Hi Kamil,
Ok, what if I want to insert a record on the Problem table with few reference fields and text fields.
How to write the script in the Scripted REST API, using POST method
Can you please give me the script?
Regards,
Pallavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 05:55 AM
For PRB, there is no dependent relation like it is REQ-RITM, thus you can just insert it the way you have it in your screenshot in the first picture, just change the table from "sc_req_item" to "problem" and adjust the fields accordingly
/* If my response wasn’t a total disaster ↙️ ⭐ drop a Kudos or Accept as Solution ✅ ↘️ Cheers! */
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-18-2024 06:14 AM
No No,
I tried it, it.s not coming.
I understand it has to be something in the object format and using JSON.Stringify method it will be taken into resposne body.
Regards,
Pallavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2024 04:52 AM
Hello all,
I have seen this link, to create a Service request from REST API Explorer.
Submit catalog request using Service catalog API - ServiceNow Community
My question is
Can we do the same thing using Scripted REST API? If so, how?
Can you please explain me?
Regards,
Pallavi
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
10-20-2024 09:33 AM
Hi,
It is indeed possible to develop your own REST API; however, it is essential to have a comprehensive understanding of the Out-of-the-Box (OOB) table API. To gain this understanding, you should navigate to the Tables section within the Table Definition menu and familiarize yourself with the relationships of the OOB tables.
I would recommend against creating a custom API, as the OOB table API is designed to meet your needs effectively. I am uncertain about the rationale behind your desire to create a personal API.
Suresh.