Controlling request and response content type

You can control which content types are allowed in scripted REST API requests and responses.

You can set default values for the service using the Default supported request formats and Default supported response formats fields. These fields define acceptable values users can pass in the Content-Type and Accept request headers respectively. If a requesting user specifies an Accept or Content-Type header not supported by the service or resource, the instance responds with an HTTP error code 406 or 415.

You can override these values for each resource using the Supported request formats and Supported response formats on the Scripted REST Resource form.
Note: The Supported request formats field only appears for PUT, POST, and PATCH resources.

You can use wildcard values when specifying valid content types.

If no accepted content types are specified, scripted REST web services support Application/json, Application/xml, and Text/xml by default.

Important: If the request body format is not Application/json, Application/xml, or Text/xml, use only the request body dataStream field to access the request body. Using request body data, dataString, nextEntry(), or hasNext() with a non-default format will result in a 500 error response.

When sending a binary type in a response, you must set the response content type and write the binary stream directly using a RESTAPIResponseStream object. You can access this object by calling getStreamWriter() on the response object.