RE: Internal Server error 500 while Suitelet script https post

I am trying to post data using the https post method. However, when I run the script, I receive error code 500. Same request successfully completed through postman. How do I resolve this issue? Please help!

/**
*@NApiVersion 2.x
*@NScriptType Suitelet
*/
define([‘N/record’,’N/redirect’,’N/search’,’N/url’, ‘N/https’,’N/encode’,’N/ui/serverWidget’,’N/runtime’], function(record, redirect,search,url,https,encode,serverWidget,runtime) {
const tokenUrl = ‘abc’;

const apiUrl = “xyz”;

function onRequest(context){

var request = context.request;
var response = context.response;

headers = {
‘Authentication’: tokenUrl,
‘accept’: ‘application/json’,
‘Content-Type’ : ‘application/json’
};

body={
bodydata
}

log.debug(“headers”,headers);
log.debug(“body”,body);

var code = https.post({
url: apiUrl,
body: body,
headers: headers

});

log.debug(‘code’, code);

}
return {
onRequest: onRequest
}
});

Maira S Beginner Asked on February 20, 2023 in SuiteScript.
Add Comment
1 Answers

Hi,

I see you recently asked a similar question and I have replied on that thread. Did you resolve that issue?

In any case, could please share some screenshots of your Suitelet deployment. In particular, audience, roles, etc?

Thanks,

Chris

Intermediate Answered on February 23, 2023.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.