Creating a Content–Type Header
Depending on how the RESTlet is written, calls to that RESTlet may require a request body and the RESTlet may return data which you want to use.
When a RESTlet requires a request body, you must tell NetSuite how your request body will be formatted. When a RESTlet returns data, you might want to specify the format of the data that is returned. Both of these formats must be the same. You specify these formats by adding a Content-Type header to your request. When a Content-Header is required but is missing, the request fails with an http error code reading 206: Partial Content
.
Supported Content-Type headers are:
-
application/json – This is the appropriate format to use for most RESTlets that require a request body because it allows you to map values to fields.
-
application/xml – This is the appropriate format to use for the get method.
-
text/plain – This is the appropriate function to use for RESTlets that require limited or simple input because it does not allow you to map values to fields.
Content-Type headers are case-sensitive and must be specified as follows:
-
Content-Type: application/json
-
Content-Type: application/xml
-
Content-Type: text/plain
For an example of a shell script that generates a Content-Type header, see Example of a Shell Script that Calls a RESTlet.