Edit on GitHub

Formats

ServiceStack supports 6 response formats out of the box:

  • JSON
  • XML
  • SOAP 1.1/1.2
  • JSV (hybrid CSV-style escaping + JSON format that is optimized for both size and speed)
  • CSV
  • HTML5 Report (provides a readable and semantic HTML layout letting you visualize all the data returned by your web service)
  • HTML with Markdown Razor (Razor combined with markdown)

Additional Formats

Additional Formats are available as external Plugins:

Rest endpoint

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.

Default endpoint

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

Examples:

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

SOAP endpoint

The SOAP endpoint only supports XML of course.

Tip: If you have forgotten the details about the specific endpoints, you can re-read this article