Hello! Has anyone attempted to return various stat...
# suitescript
j
Hello! Has anyone attempted to return various status codes in a Suitelet response? We're attempting to integrate NetSuite using a webhook, and lacking a middleware, we plan to utilize a Suitelet as a listener. Different status codes are expected to arming an endpoint.
It appears to be a limitation, but I'm just trying my luck here.
e
AFAIK. we have no control over the status code coming out of a Suitelet or Restlet. If it returns normally, you get a
200
. If it throws, you get a
400
. Every significant integration I've built or seen always returns their own status code in the output. That's not useful in every situation I know.
s
yes, this is a limitation we’ve dealt with when building integrations to Netsuite for years, and I would agree that embedding a status code and status message in every response is very useful, provided you can configure the calling client to inspect those properties and use them in place of the actual HTTP status code. With some clients it may not be possible. In such a situation, building your own middleware service to live between the two may be necessary, so you can then control the headers and response codes.
j
Middleware it is. Thanks for confirming 🙂
m
Doesn't help with suitelets, but the release notes for 2024.2 indicates a new
N/scriptTypes/restlet
module to define a custom HTTP response. They only mention headers, but maybe it'll let us set status codes as well.