Header Value: application / vnd.api + json

Can someone explain the difference between:

application/vnd.api+json 

as well as

 application/json 
+79
json rest api
Jan 20 '15 at 21:32
source share
5 answers

The media type application/vnd.api+json is a JSON API. You can read more about this here .

In short, the JSON API is stubborn and argumentative:

... a specification of how the client should request these resources retrieved or modified, and how the server should respond to these requests.

+71
Mar 17 '15 at 21:08
source share

The first is an API specific media type. The vendor prefix ( vnd. ) Indicates that it is common for this provider. +json indicates that it can be parsed as JSON, but the media type should define additional semantics on top of JSON.

The second means that the content is JSON. This is generally not very useful because it does not define JSON values.

Wikipedia is a good starting point to read about this, but for more information, you can always follow the links to the relevant RFCs on this page.

+50
Jan 27 '15 at 9:10
source share

If you are not sure, use application/json - this is a universal MIME type that requires that the returned data is only properly formed JSON .




The MIME type application/vnd.api+json reserved for communication using the JSON API protocol (with a strange name).

"JSON API" in this context does not mean any API based on HTTP and JSON. It is also not a fully defined API - rather, it is a platform for creating APIs that allow the client to retrieve and modify related objects. For example, a blog application may implement an API that conforms to the "JSON API" specification, which allows you to retrieve the last 10 articles of a given author with metadata and comments for each article in a single HTTP request.

The specification defines, in particular:

  • a specific method for generating the request (i.e. which URL parameters control the sorting and pagination and the data included in the output);
  • The specific structure of the JSON document in the response, for example:

    The document MUST contain at least one of the following top-level members:

    • data : documents "primary data"
    • errors : array of error objects
    • meta : a meta object that contains non-standard meta information.

    data and errors MUST NOT coexist in the same document.

+26
Apr 13 '17 at 14:22
source share

The multifunctional type of Internet mail extensions (MIME) (or) the type of medium is a standardized way of indicating the nature and format of a document transmitted over the Internet. It is standardized in IETF RFC 6838 . The Internet Assigned Numbers Authority (IANA) is the official body responsible for tracking all official MIME types.

The media type used by the JSON API is application / vnd.api + json , and it has been properly registered with IANA.

The type of multimedia API + JSON is intended for the interaction of various APIs serving JSON.

It was created taking into account the clients of "thick JavaScript" and their needs, but is not specific to them. So, with the prefix vnd (provider).

Add a few more points to the JSON API:

  • The JSON API is a specification that defines the API specification of what the request and response should be.
  • Allows us to create well-defined structures (e.g. links between resources and links, etc.)
  • Indicates how REST APIs should respond to CRUD operations.
  • Allows the client to cache responses.
+3
May 16 '18 at 17:53
source share

If you need to customize the application / vnd.hmrc.1.0 + json header below

Then you have to go with

 Accept: application/vnd.hmrc.1.0+json 

Using CUrl, you can run the script as

 $url="https://test-api.service.hmrc.gov.uk/hello/world"; $ch = curl_init(); $curlConfig = array( CURLOPT_URL => $url, CURLOPT_HTTPHEADER => array('Accept: application/vnd.hmrc.1.0+json') ); curl_setopt_array($ch, $curlConfig); $result = curl_exec($ch); curl_close($ch); 

Hope it helps !!

0
Oct 23 '18 at 10:24
source share



All Articles