Anyone found a way or manage to return proper/vali...
# suitescript
a
Anyone found a way or manage to return proper/valid HTTP codes in RESTlet response? or there is just 2 options 200 and 400 when throwing an error?
s
My team has settled on a practice of having all Restlet responses be an Object that always contain a few properties: a success boolean, a message string, a responseCode number. Any code calling the restlets is instructed to basically ignore the actual response code, and instead check those fields to determine the actual success and response code of the call. Given the limitations, I think the best thing is just to have some kind of agreed upon contract with the calling client, and then adhere to that, letting them know that you can’t control the actual HTTP response code, so it can be misleading.
a
Yes, this is what we are doing, but just wondering if somebody found a TRICK, looks like is not possible. because there is no access to the http.Response object.
s
If there is a way, it’s totally undocumented, so it might not be reliable. We never found any trick to do it, though.
m
I've just wrapped up a project where we used amazon's API gateway (no lambda) to re-write the response and return correct status codes. Still annoying we had to but did we did get control over the domain name as well, the end result was great but we now have to manage 2 systems.
s
Yes, using an intermediate system is another approach, and one that we have used in the past as well. On the positive side, you can control the responses, and even add retry logic or queuing. But, it also adds additional latency and increases maintenance, so there are definitely trade-offs. We decided to abandon that in favor of a more direct approach, with the logic embedded directly in the calling code, for performance reasons.