7px
11/16/2022, 3:38 AMhttps.get()
. I can successfully pass values through it using the headers
parameter, and accessing them from the redirected HTML through a URLSearchParams
object. This works great when the suitelet is calling the GET function, but when calling the POST function and running the same steps of passing values through headers, it doesn't make it to the HTML. Does POST follow a different ruleset for passing values or should I pass values differently?
Any and all input appreciated, thanks.7px
11/16/2022, 3:39 AM/**
* @NApiVersion 2.1
* @NScriptType Suitelet
*/
define(['N/https', 'N/record', 'N/email', 'N/search', 'N/log', 'N/url'],
function callbackFunction(https, record, email, search, log, url) {
function getFunction(context) {
let id = 7;
let usr = 'seven';
let headerObj = ({ 'user': usr, 'userid': id });
let contentRequest = https.get({ url: "<https://website_stored_in_file_cabinet_1.html>", headers: headerObj });
context.response.write(contentRequest.body);
}
function postFunction(context) {
let params = context.request.parameters;
/* creating record from param values */
let newRecID = newRec.save();
let newRecURL = url.resolveRecord({ isEditMode: false, recordId: newRecID, recordType: "customrecord_idaud" });
let _fname = "name";
let _id = 77;
let headOb = ({ 'fname': _fname, 'uid': _id });
let conReq = https.get({ url: "<https://website_stored_in_file_cabinet_2.html>", headers: headOb });
context.response.write(conReq.body);
}
function onRequestFxn(context) {
if (context.request.method === "GET") {
getFunction(context)
}
else {
postFunction(context)
}
}
return {
onRequest: onRequestFxn
};
});
battk
11/16/2022, 7:48 AMbattk
11/16/2022, 7:48 AMbattk
11/16/2022, 7:48 AM7px
11/16/2022, 7:55 AM