RESTlet Return Type Difference
SuiteScript 2.1 changes the way that RESTlet responses are formatted for certain content types. When the Content-Type in the RESTlet header does not match the type that the RESTlet is returning, the results returned may not be what you are expecting.
|
Scenario |
SuiteScript 2.0 Behavior |
SuiteScript 2.1 Behavior |
|---|---|---|
|
Set the Content-Type in a RESTlet header to application/json. For example, the following sample RESTlet script and sample code for calling the RESTlet.
|
The response is automatically converted to a string and that string is returned instead of an object. In the example scenario, the alert output is a string, SS2.0 gives string; but in SS2.1 it comes as object. |
The return type for JSON will be an object. In the example scenario, the alert output is an object. |