How to write scripted rest API to create RITM and pass field values and attachment using POSTMAN
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 02:15 AM
How to write scripted rest API to create RITM and pass field values and attachment using POSTMAN.
Regards,
Nikita

- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 02:28 AM
Hi Nikita,
you can use the following article as good example and arrange it as per your requirement:
If I have answered your question, please mark my response as correct and/or helpful.
Thank you very much
Cheers
Alberto
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
05-11-2020 02:38 AM
Hi Nikita,
please find sample script which you can use in scripted rest api
Ensure you accept the variable information from the json request
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
//add your requested item to the cart by sys_id of the catalog item
var item = cart.addItem('4054428fdb151f0097679ec6db9619c0', 1);
//fill in the variables on the request item form
cart.setVariable(item,"variable_1", "hello");
cart.setVariable(item,"variable_2", "test");
var rc = cart.placeOrder();
var ritm = new GlideRecord('sc_req_item');
ritm.addQuery('request.number', rc.number);
ritm.query();
if(ritm.next()){
ritmNumber = ritm.number;
}
// return in response the REQ and RITM Number and status as success
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
05-11-2020 03:52 AM
Hi Ankur,
Thanks for replying. but my requirment is different. I want to pass RITM field values and attachment using POSTMAN. i am having difficulty in attachment while creating new RITM.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
08-31-2022 03:38 AM
Hi Nikita,
Hope you have get the solution, can you please share.I have the same requirement.
TIA 🙂