Community Tip - Did you get an answer that solved your problem? Please mark it as an Accepted Solution so others with the same problem can find the answer easily. X
Is it possible to write a Thingworx service in Javascript to return custom 400 - 500 level error codes for when the service is being called via REST? Or does REST calls to a custom Thingworx service only return the standard defined set of response codes, including error codes?
Hi @SG_9149098 ,
Thanks for the response anarwal. Do you happen to have an example of returning 400 or 500 level error codes in Thingworx javascript? It seems javascript functionality in Thingworx is a little more restricted versus some of the javascript functionality available outside of Thingworx.
So I'm getting the impression that the Thingworx product is incapable of allowing a developer to define and return specific HTTP response status codes back the the caller like what is capable on other platforms. The caller will only receive a 200 level response code or an error message. Defining specific 400 or 500 level response codes in Thingworx services is not possible on the Thingworx platform. Is this a true statement?
You are correct. The JS services will return 200 on success or 500 upon error. The message you use in the error output is what will be passed in the 500 result. You do not have control over the HTTP response codes as a script developer.
I will try it out. Thanks
Hi @SG_9149098.
If you feel your question has been answered (even if it was not the answer you wanted), please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon
Hi @SG_9149098.
If you feel your question has been answered, please mark the appropriate response as the Accepted Solution for the benefit of others with the same question.
Regards.
--Sharon