Edit on GitHub

Content Types

ServiceStack supports the following formats:

.NET Service Clients

The different Content Types can be easily consumed using ServiceStack’s Typed Generic Service Clients.

HTTP/REST Endpoints

You can define which format should be used by adding a .{format} extension:

  • .json
  • .xml
  • .jsv
  • .csv
  • .html

Or by appending ?format={format} to the end of the URL:

  • ?format=json
  • ?format=xml
  • ?format=jsv
  • ?format=csv
  • ?format=html

Example: http://test.servicestack.net/hello/World!?format=json

Alternatively ServiceStack also recognizes which format should be used with the Accept http header:

  • Accept: application/json
  • Accept: application/xml

As you can see, this approach only works with json and xml.

Pre-defined Routes

/[xml|json|html|jsv|csv]/[reply|oneway]/[servicename]

Examples:

  • /json/reply/Hello (JSON)
  • /xml/oneway/SendEmail (XML)

Forcing a Content Type

Whilst ServiceStack Services are typically available on any endpoint and format, there are times when you only want adhoc Services available in a particular format, for instance you may only want the View Models for your dynamic Web Views available in HTML. This can now be easily enabled with the new [HtmlOnly] Request Filter Attribute, e.g:

[HtmlOnly]
public class HtmlServices : Service
{
    public object Any(MyRequest request) => new MyViewModel { .. };
}

This feature is also available for other built-in Content Types: [JsonOnly], [XmlOnly], [JsvOnly] and [CsvOnly].

SOAP Endpoint

Consume ServiceStack Services via SOAP using WCF Add Service Reference or ServiceStack generic SOAP Clients.

MQ Endpoint

Consume ServiceStack Services via Message Queue.