Anybody know if it is possibible to call a RESTlet...
# suitescript
r
Anybody know if it is possibible to call a RESTlet from a UE script? I have a UE script that calls a RESTlet in the same account. But I get a 500 error code in the UE script when it calls the RESTlet.
a
RESTlets are designed to be used from outside of NetSuite, so while I don't think there's anything preventing you from doing that from inside a NS from a UE... the RESTlet would still expect to authorize the access, and I'm assuming you've not setup the authorization correctly in your UE... cos you're probably thinking you don't need to Auth cos you're already inside of NS?
I'm just speculating because I don't think I've ever tried to anything like that, but it just seems like a wrong design to be calling a restlet from a UE
if you're doing the same thing in your UE that you already do in your restlet... I'd suggest pulling that code into a library instead, and then having both the RESTlet and the UE use that same library code, rather than have the UE use the RESTlet
actually it is possible NS just forbid that entirely, as it could be a way to work around their concurrency/usage model? again, purely specultation on my part
r
The UE script needs to update related records that might cause it to exceed the Usage Limits. I was experimenting with using the UE to send each record to process to a RESTlet, to make it more "real-time" compared to calling an MR or Scheduled script. I was able to use the same approach for Suitelets on the Server Side, so I guess I was hoping it was possible with UE scripts too.
a
you're using a suitelet to call a reslet?
r
Yes
a
and that works without issue? but you can't do the same thing from a UE?
r
To circumvent the Usage Limits due to the volume of data that the suitelet needed to process
Yes it worked fine in the Suitelet
a
that's really unexpected, I can't think of a reason why one server side script type (suitelet) would perform differently from another server side script (UE) for this use case.
you CAN call a suitelet from a UE... so ... ok this is getting weird... you could potentially call the suitelet from a UE and have the suitelet call your restlet? 😂
you know you can trigger a MR from a UE with the task module right? that close to realtime too, you don't have to use the schedule on an MR
r
Yeah, but it can sit in the queue if there are other scripts running. I'll just probably do that instead
a
for the suitelet >> Restlet usecase... don't they both have 5k governance? or am i remembering that wrong? not sure how you get more usage out of a restlet than a suitelet?
oh also, idk if this would be helpful for your use case but its possible to create a .csv file in your US and trigger a csv import to do your updates... that can also avoid governance limits and help with performance if creating the .csv isn't a too difficult
m
@rustyshackles How are you calling the restlet specifically? Also, maybe check the permission on the restlet.
w
you can use this https module method, and call it from a UE without any authentication as long as the UE and the Restlet are within the same account context. https://docs.oracle.com/en/cloud/saas/netsuite/ns-online-help/section_159139340774.html
r
I am using https.requestRestlet. @Matt Carter and @wbermudo
@Anthony OConnor It is more of instead the Suitelet processing all the record, I pass each record to the RESTlet, so this avoids the Usage Governance, in terms of Usage Unit and Execution Time.
r
You are still waiting for the response to get back from the restlet. Your user limit could hit the 5 minute execution time limit. Also gives a bad user experience. And https calls also uses governance usage. So calling the same restlet multiple times, you can still hit governance usage. Or may end up with concurrency issues with the restlet. Idk your use case, so can't say for sure. But generally speaking user events + MR would have been the ideal design.