Postman

Header 和 Params  的区别:
 

Headers

The REST headers and parameters contain a wealth of information that can help you track down issues when you encounter them. HTTP Headers are an important part of the API request and response as they represent the meta-data associated with the API request and response. Headers carry information for:

  1. Request and Response Body
  2. Request Authorization
  3. Response Caching 
  4. Response Cookies

Other than the above categories HTTP headers also carry a lot of other information around HTTP connection types, proxies etc. Most of these headers are for management of connections between client, server and proxies and do not require explicit validation through testing.

Headers are mostly classified as request headers and response headers, know the major request and response headers. You will have to set the request headers when you are sending the request for testing an API and you will have to set the assertion against the response headers to ensure that right headers are being returned.

The headers that you will encounter the most during API testing are the following, you may need to set values for these or set assertions against these headers to ensure that they convey the right information and everything works fine in the API:

Authorization: Carries credentials containing the authentication information of the client for the resource being requested.

WWW-Authenticate: This is sent by the server if it needs a form of authentication before it can respond with the actual resource being requested. Often sent along with a response code of 401, which means ‘unauthorized’.

Accept-Charset: This is a header which is set with the request and tells the server about which character sets are acceptable by the client.

Content-Type:  Indicates the media type (text/html or text/JSON) of the response sent to the client by the server, this will help the client in processing the response body correctly.

Cache-Control: This is the cache policy defined by the server for this response, a cached response can be stored by the client and re-used till the time defined by the Cache-Control header.

Parameters

REST parameters specify the variable parts of your resources: the data that you are working with. As was mentioned in a previous article Understanding REST & SOAP Request Methods, in a REST request the resource that you are working with is specified in the URL – Uniform Resource Locator. The URL is a special case of the URI – Uniform Resource Identifier – which consists of four parts:

scheme_name:hierarchical_part?query#fragment

In the article detailing the SOAP vs. REST debate we discussed that REST is not a standard in itself, but instead makes extensive use the HTTP standard. Therefore for all REST calls, the scheme name will always be “http:”, or “https:” if sent over a secure channel.

 

---------------------------------------

get: params, 就是放在URL后面的query字符串, ?q=b&c=d
post: body 里面含有, form-data,  x-www-form-urlencoded, 可以带文件,
content type: 一些预定义的头部, 相当于metadata,  也可以自定义。。。

 

==========================

 

 

posted @ 2020-07-10 16:33  qqisnow2021  阅读(155)  评论(0编辑  收藏  举报