Previous Page Arrow Next Page Arrow

Requesting JSON formatted SData content

The JSON and atom+xml formats are of equal importance from a protocol perspective - a difference to the SData 1.x . Consequently, the desired format of a response is specified by the consumer in its request.

If a consumer wants to be certain to get a response in the SData JSON format, it will request this using the “application/json;vnd.sage=sdata” media type. This is achieved in two ways:

  1. through the HTTP Accept header:
    Accept: application/json;vnd.sage=sdata
  2. using format query parameter on the request URL:

    http://www.example.com/sdata/myApp/myContract/prod/accounts?format=application/json;vnd.sage=sdata

The first mechanism should be used when the consumer (the user agent) will systematically request the JSON format. The second one is more appropriate when the consumer normally uses ATOM but switches to JSON occasionally.

Default formats of a contract

A contract may be particularly suitable to one or the other formats (ex: a contract for mobile devices will very likely return JSON). In such cases, for expedience and ease of programming, a default response format can be defined at the contract level. The default format will be returned when requests without a specific media type are sent to a provider.

The SData JSON format MAY be returned by an application by default when:

  • it is the default format for contract
  • JSON responses are per default conformant to the SData structural requirements

Previous Page Arrow Next Page Arrow