Hi, how to send a POST request to a back-end suite...
# suitescript
j
Hi, how to send a POST request to a back-end suitelet from a user event script?
b
the basic answer is to use the code from the suitelet in your user event script instead
the new intermediate answer is to use a restlet instead and use https.requestRestlet
the advanced hacky answer is that internal suitelet urls require a vaiid JSESSIONID cookie to be sent. If your user event is triggered from the ui, you can retrieve the JSESSIONID cookie from the user for use in the user event script, where you can send the cookie in your request
j
the code is already at the userevent level but planning to moved it to either suitelet or restlet. I'm thinking of using suitelet since it is an internal call/request only.
it is triggered both on UI and backend level.
b
i personally will tell you to leave the code in the user event
if you want to use it in multiple places, put the code in a custom module that is shared between your scripts
j
the code needs two create 2 transaction types. putting it on a userevent will slowdown the process that's why I'm planning to moved it to another script type and then trigger it via userevent.
b
the suitelet will be slower
the code will take the same amount of time, plus transport time from https
j
The plan is to trigger the suitelet only and don't need to wait the response.
it will be like calling an adhoc scheduled script.
b
asynchronous code is usually done via tasks
j
I can't used sched script because we already have problems on processors utilization that's why I'm thinking of other ways to do it.
b
you cant make the https request asynchronous