API - Other

OPTIONS Method

We use This method to get information about the possible communication options (Permitted HTTP methods) for the given URL in the server or an asterisk to refer to the entire server. This method is safe and idempotent.


Returns permitted HTTP method in this URL

/api/index.html/1.1


Returns all permitted methods

*HTTP/1.1

PATCH Method

PATCH is another HTTP method that is not commonly used. Similar to PUT, PATCH updates a resource, but it updates data partially and not entirely.


For customer 123, it updates the name to "Sally"

/api/customers/123

Request Body
{
  "name": "Sally"
}

POST Method

The POST method creates a new resource on the backend (server). The request body carries the data we want to the server. It is neither a safe nor idempotent method. We don't expect to get the same result every time we send a POST request.


Create an Account Item

/api/customers/accounts


Creates an Account Item using the provided Customer ID and Account ID

/api/customers/123/accounts/111/account-items

PUT Method

With the PUT request method, we can update an existing resource by sending the updated data as the content of the request body to the server. The PUT method updates a resource by replacing its entire content completely.


Update customer by Customer ID

/api/customers/123

Referrer-Policy

The Referrer-Policy HTTP header controls how much referrer information (sent with the Referer header) should be included with requests. Aside from the HTTP header, you can set this policy in HTML.


Syntax

Referrer-Policy: no-referrer
Referrer-Policy: no-referrer-when-downgrade
Referrer-Policy: origin
Referrer-Policy: origin-when-cross-origin
Referrer-Policy: same-origin
Referrer-Policy: strict-origin
Referrer-Policy: strict-origin-when-cross-origin
Referrer-Policy: unsafe-url


Directives

  • no-referrer - The Referrer header will be omitted: sent requests do not include any referrer information.
  • no-referrer-when-downgrade - Send the origin, path, and query string in Referrer when the protocol security level stays the same or improves (HTTP → HTTP, HTTP → HTTPS, HTTPS → HTTPS). Don't send the Referrer header for requests to less secure destinations (HTTPS → HTTP, HTTPS → file).
  • origin - Send only the origin in the Referrer header. For example, a document at https://example.com/page.html will send the referrer https://example.com/.
  • origin-when-cross-origin - When performing a same-origin request to the same protocol level (HTTP → HTTP, HTTPS → HTTPS), send the origin, path, and query string. Send only the origin for cross origin requests and requests to less secure destinations (HTTPS → HTTP).
  • same-origin - Send the origin, path, and query string for same-origin requests. Don't send the Referrer header for cross-origin requests.
  • strict-origin - Send only the origin when the protocol security level stays the same (HTTPS → HTTPS). Don't send the Referrer header to less secure destinations (HTTPS → HTTP).
  • strict-origin-when-cross-origin (default) - Send the origin, path, and query string when performing a same-origin request. For cross-origin requests send the origin (only) when the protocol security level stays same (HTTPS → HTTPS). Don't send the Referrer header to less secure destinations (HTTPS → HTTP).


Integration with HTML

You can also set referrer policies inside HTML. For example, you can set the referrer policy for the entire document with a <meta> element with a name of referrer:

<meta name="referrer" content="origin" />


You can specify the referrerpolicy attribute on <a>, <area>, <img>, <iframe>, <script>, or <link> elements to set referrer policies for individual requests:

<a href="http://example.com" referrerpolicy="origin">…</a>


Alternatively, you can set a noreferrer link relation on an a, area, or link elements:

<a href="http://example.com" rel="noreferrer">…</a>


TRACE Method


The TRACE method method is used to perform a message loop back test that tests the path for the target resource (useful for debugging purposes).


Responds the exact request that client sent

/api/index.html

Type Of HTTP Methods

  • GET
  • POST
  • PUT
  • PATCH
  • DELETE
  • HEAD
  • OPTIONS
  • TRACE
  • CONNECT