0
我正在學習腳本化REST API的過程。我有一個在用戶進行POST時創建REQ和RITM的。我無法將其他帖子中的變量填充到RITM中。以下是我目前的代碼。響應是RITM,請求者和簡短描述。我願意接受所有建議,就像我說我正在飛行中學習這樣,所以如果有任何明顯的問題,我都會接受。謝謝!從REST調用填充RITM變量
(function process(/*RESTAPIRequest*/ request, /*RESTAPIResponse*/ response) {
var cartId = GlideGuid.generate(null);
var cart = new Cart(cartId);
var item = cart.addItem('25409830135aa20099fc7e776144b0a0');
var rc = cart.placeOrder();
var req = request.getHeader('ContactEmployeeId');
var sdesc = request.getHeader('ShortDescription');
//return rc.number;
//gs.addInfoMessage(rc.number);
var num = rc.sys_id; //get sys ID of newly created request
var rnum = 0;
//using the request number, query the RITM table for related RITM
var u = new GlideRecord('sc_req_item');
u.addEncodedQuery('request='+num);
u.query();
while (u.next())
{
rnum = u.number;
}
response.setBody({
Requested_Item: rnum,
u_requester: req,
short_description: sdesc
});
response.setContentType('application/json');
})(request, response);
請問您的請求體是怎麼樣的,請提供您的請求有效載荷樣本 – Rafay