how to use a CartJS for scripted rest api.
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 02:57 AM
when i am trying to apply a CartJS in scripted rest api while testing through a postman i am getting
error - "
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-16-2023 03:54 AM
Hi Rahul,
I had done the same thing and it worked for me. I created a scripted rest API "cartapitest" and then a POST resource called "createRequest", then from Postman I passed the URL "https://xxxxxx.service-now.com/api/760201/cartapitest". I used Basic Auth, in the header I passed a value which I used in the scripted rest API script using the method "request.getHeader()" which I then passed in my CartAPI script.
var cart = new sn_sc.CartJS();
var request1 = {
'sysparm_id': '039c516237b1300054b6a3549dbe5dfc',
'sysparm_quantity': '1',
'variables': {
'abc': request.getHeader('short_description')
}
};
var cartDetails = cart.orderNow(request1);
This creates the request correctly and maps the variable too.
gs.info(cartDetails);
- Mark as New
- Bookmark
- Subscribe
- Mute
- Subscribe to RSS Feed
- Permalink
- Report Inappropriate Content
02-21-2023 08:05 AM
how to use a variable set using cartjs.