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.

Rookie Asked on November 23, 2021 in SuiteScript.
Add Comment
2 Answer(s)

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

Looks like I found an alternative way to get data back out of Netsuite via a saved search RESTlet.

With my own integration, I can set up a polling server to get the results of the saved search and act on that.

Rookie Answered on November 26, 2021.
Add Comment

Your Answer

By posting your answer, you agree to the privacy policy and terms of service.
  • This site made possible by our sponsors:   Tipalti   Celigo   Limebox   Become a Sponsor