Skip to content

Commit 495ace8

Browse files
committed
Permit clients to require a profile via the accept header.
1 parent c468fbe commit 495ace8

File tree

1 file changed

+29
-18
lines changed

1 file changed

+29
-18
lines changed

_format/1.1/index.md

Lines changed: 29 additions & 18 deletions
Original file line numberDiff line numberDiff line change
@@ -37,7 +37,7 @@ Clients and servers **MUST** send all JSON:API data using this media type in the
3737

3838
Further, the JSON:API media type **MUST** always be specified with either no
3939
media type parameters or with only the `profile` parameter. This applies to both
40-
the `Content-Type` and `Accept` headers.
40+
the `Content-Type` and `Accept` headers whenever they are present.
4141

4242
> Note: A media type parameter is an extra piece of information that can
4343
accompany a media type. For example, in the header
@@ -48,9 +48,6 @@ The `profile` parameter is used to support [profiles].
4848

4949
### <a href="#content-negotiation-clients" id="content-negotiation-clients" class="headerlink"></a> Client Responsibilities
5050

51-
Clients that include the JSON:API media type in their `Accept` header **MUST**
52-
specify the media type there at least once without any media type parameters.
53-
5451
When processing a JSON:API response document, clients **MUST** ignore any
5552
parameters other than `profile` in the server's `Content-Type` header.
5653

@@ -61,8 +58,14 @@ a request specifies the header `Content-Type: application/vnd.api+json`
6158
with any media type parameters other than `profile`.
6259

6360
Servers **MUST** respond with a `406 Not Acceptable` status code if a
64-
request's `Accept` header contains the JSON:API media type and all instances
65-
of that media type are modified with media type parameters.
61+
request's `Accept` header contains the JSON:API media type and the server is
62+
unable to respond with an acceptable representation. The response **MUST** contain
63+
an [error object] which lists the unsupported profile or profiles as
64+
its `source` and which has the following URI as (one of) its `type`s:
65+
66+
```
67+
https://jsonapi.org/errors/profile-not-supported
68+
```
6669

6770
> Note: These content negotiation requirements exist to allow future versions
6871
of this specification to add other media type parameters for extension
@@ -1908,26 +1911,32 @@ parameter **MUST** equal a space-separated (U+0020 SPACE, " ") list of profile U
19081911
> (U+0022 QUOTATION MARK, "\"") if it contains more than one URI.
19091912
19101913
A client **MAY** use the `profile` media type parameter in conjunction with the
1911-
JSON:API media type in an `Accept` header to _request_, but not _require_, that
1912-
the server apply one or more profiles to the response document. When such a
1913-
request is received, a server **SHOULD** attempt to apply the requested profiles
1914-
to its response.
1914+
JSON:API media type in an `Accept` header to request that the server apply one
1915+
or more profiles to the response document. When such a request is received, a
1916+
server **SHOULD** attempt to apply the requested profiles to its response.
19151917

19161918
For example, in the following request, the client asks that the server apply the
1917-
`http://example.com/last-modified` profile if it is able to.
1919+
`http://example.com/last-modified` profile if it is able to. If the server is
1920+
unable to apply the profile, it may send a response without the profile applied
1921+
because the client also specified the JSON:API media type without the `profile`
1922+
media type parameter.
19181923

19191924
```http
19201925
Accept: application/vnd.api+json;profile="http://example.com/last-modified", application/vnd.api+json
19211926
```
19221927

1923-
> Note: The second instance of the JSON:API media type in the example above is
1924-
required under the [client's content negotiation responsibilities](#content-negotiation-clients).
1925-
It is used to support old servers that don't understand the profile parameter.
1928+
In the following request, the client asks the server to process its request
1929+
using the `http://example.com/boolean-filters` profile. In this case, the client
1930+
does not specify the bare JSON:API media type because it would not like a
1931+
response unless the request was processed using the specified profile.
1932+
1933+
```http
1934+
Accept: application/vnd.api+json;profile="http://example.com/boolean-filters"
1935+
```
19261936

1927-
Servers **MAY** add profiles to a JSON:API document even if the client has not
1928-
requested them. The recipient of a document **MUST** ignore any profiles in that
1929-
document that it does not understand. The only exception to this is profiles
1930-
whose support is required using the `profile` query parameter, as described later.
1937+
Servers **MAY** process messages using one or more profiles even if the client has
1938+
not requested them. The recipient of a document to which an unknown profile
1939+
has been applied **MUST** ignore any document members that it does not understand.
19311940

19321941
#### <a href="#profiles-sending" id="profiles-sending" class="headerlink"></a> Sending Profiled Documents
19331942

@@ -2325,6 +2334,8 @@ An error object **MAY** have the following members:
23252334
exists; if it doesn't, the client **SHOULD** simply ignore the pointer.
23262335
* `parameter`: a string indicating which URI query parameter caused
23272336
the error.
2337+
* `profiles`: an array of the requested profile URIs that the server was not
2338+
able to support.
23282339
* `meta`: a [meta object][meta] containing non-standard meta-information about the
23292340
error.
23302341

0 commit comments

Comments
 (0)
pFad - Phonifier reborn

Pfad - The Proxy pFad of © 2024 Garber Painting. All rights reserved.

Note: This service is not intended for secure transactions such as banking, social media, email, or purchasing. Use at your own risk. We assume no liability whatsoever for broken pages.


Alternative Proxies:

Alternative Proxy

pFad Proxy

pFad v3 Proxy

pFad v4 Proxy