REST Response Output Formats

You can explicitly specify the format of the data returned by the REST service at the end of the path information, as shown in the following examples.

If the output is not explicitly specified at the end of the path information (as described in the previous examples), the REST application attempts to deduce the required output from the REST request header.

REST requests can contain an Accept header field. The Accept header field is used by the client to signal to the REST server which content types it can process. The following are examples of Accept header fields that could be used when sending requests.

Accept: */*
Accept: image/png
Accept: application/json
Accept: application/xml
Accept: application/json, application/xml

If the Accept header field:

REST requests with payloads should contain a Content‑Type header field. The Content‑Type header field is used by the client to tell the REST server the format of the request payload. The following are examples of Content‑Type header fields that could be used when sending requests.

Content-Type: application/xml
Content-Type: application/json
Content-Type: text/html; charset=utf-8
Content-Type: multipart/form-data; boundary=ExampleBoundaryString

If the Content‑Type header field:

The determination of output formats applies only to REST methods that return non‑primitive objects that will be automatically serialized by the REST service. The output format also affects the encoding of String primitive type values returned from REST methods when the value of the JadeRestService class encodeResponseString property is set to true.