RE: How would I make a WorkflowActionScript that can send a POST message?

Hi there everyone, first time posting and first time working with Netsuite.

I’ve been trying to figure out how to build some WorkflowActionScript where on this step in the workflow, it would send the “ScriptContext” to another application.

I’ve got a script deployed like that looks like this…

/**
 * @NApiVersion 2.0
 * @NScriptType WorkflowActionScript
 * @NModuleScope public
**/
define(["N/https", "N/log"], function (https, log) {
    function onAction(scriptContext) {
      log.debug(scriptContext);
      return https.post({
        url: "https://myapp.com/netsuite",
        body: JSON.stringify(scriptContext),
      });
    }
  
    return {
      onAction: onAction,
    };
  });

But it doesn’t seem to be working. Using Postman, I can POST a message to my endpoint and receive it. It seems like when the source is Netsuite, it won’t work and I’m not sure what I’ve done that isn’t working.

sunshineinabag Rookie Asked on November 23, 2021 in SuiteScript.
Add Comment
2 Answers

Fair chance you need to also set some headers. Postman uses a bunch of auto generated headers, Common ones that servers actually use are the Content-Type and Accept headers.

Advanced Answered on November 23, 2021.
Add Comment

Your Answer

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