《2022年Postman使用手册.docx》由会员分享,可在线阅读,更多相关《2022年Postman使用手册.docx(18页珍藏版)》请在taowenge.com淘文阁网|工程机械CAD图纸|机械工程制图|CAD装配图下载|SolidWorks_CaTia_CAD_UG_PROE_设计图分享下载上搜索。
1、Postman 使用手册Sending requests-发送恳求The Postman interface is divided into two areas. The sidebar on the left and the request builder on the right. The request builder lets you create almost any kind of request quickly. The four parts of anrequest are the URL, method, headers, and the body. Postman give
2、s you tools to work with each of these parts.Postman界面分为两个区域;侧边栏左边和右边的恳求builder ;恳求构建器答应您创建几乎任何类型的恳求很快;四个部分的一个恳求的 URL, 方法,头, 身体; Postman给你工具来处理这些部分;URLThe URL is the first thing that you would be setting for a request. The URL inputfield stores URLs used previously and will show an auto complete dro
3、pdown as you begin entering your URL. Clicking on the URL params button will open up thekey-value editor for entering URL parameters.URL 的第一件事 , 你会设置恳求;从前使用的URL 输入字段储备URL 并将显示自动完成下拉当你开头进入你的网址;单击URL 参数按钮将打开键 - 值编辑器输入 URL 参数Parameters you enter in the URL bar or in the key/value editor will not automa
4、tically be URL-encoded. Right click on a piece of selected text, and click EncodeURIComponent to manually encode the parameter value.参数输入地址栏或键/ 值编辑器不会自动 URL 编码;右击选中的文本 , 然后单击 EncodeURIComponent手工编码参数值;You can individuallyadd key/value pairs and Postman willcombine everythingtogether. If your URL alr
5、eady has parameters - for example, if you are pasting a URL from some other source, Postman will split the URL into pairs automatically.您可以单独添加键 / 值对,postman会结合在一起的一切;假如你的URL 已经参数 例如, 假如你是粘贴URL 从其他来源 ,postman 将 URL 分成自动配对HeadersClicking on the headers toggle will show the headerskey-value editor. Yo
6、u can setany string as the header name. Common headers part of thespec are available in an auto-complete drop down when you begin typing the header name. Values forthe Content-Type header are also available in an auto-complete drop down.单击标题切换键值编辑器将显示头;你可以设置任何字符串作为标题名称;常见的标头部分标准在一个自动完成拉当你开头键入标题名称;“内
7、容类型 ”头的值也可以自动完成下拉;Header presetsYou can save commonly used headers together in a header preset. You can add a header preset to your request by clicking the Add preset button or by selecting the preset from the header dropdown.您可以储存常用的标题在标题预设;您可以添加一个头预定你的恳求通过单击“添加预设 ”按钮或通过挑选预设的标题下拉MethodChanging the
8、method is straightforward. Just select the method from the select control. The request body editor area will change depending on whether the method can have a body attached to it or not.转变方法很简洁;只是挑选方法从恳求主体的挑选掌握;编辑器区域将会转变取决于方法可以有身体连接到它;The ability to add additional methods and toggling whether a body
9、 can be attached to it will be added soon添加额外的方法和切换的才能是否身体可以被附加到它很快就会被添加Request bodyWhile constructing requests, you would be dealing with the request body editor a lot. Postman lets you send almost any kind ofrequest If you cant send something, let us know. The body editor is divided into 4 areas a
10、nd has different controls depending on the body type.而构建恳求 ,您将处理恳求主体编辑器;postman 让你送几乎任何类型的恳求假如你不能送东西 , 让我们知道 . ;身体编辑分为 4 个区域 ,依据身体类型有不同的掌握;form-datamultipart/form-data is the default encoding a web form uses to transfer data. Thissimulates filling a form on a website, and submitting it. The form-dat
11、a editor lets you set key/value pairs using thekey-value editor for your data. You can attach files to a key as well. Do note that due to restrictions of the HTML5 spec, files are not stored in history or collections. You would have to select the file again at the time of sending a request.多部分 / 格式数
12、据是默认编码一个web 表单使用传输数据;这对一个网站模拟填充表单, 并提交它;格式数据编辑器答应您设置键 / 值对 使用键值编辑器 为您的数据 ,您可以将文件附加到一个关键;做留意HTML5 标准的限制 , 文件不储备在历史或集合;你会挑选文件再次发送恳求的时候;,由于urlencodedThis encoding is the same as the one used in URL parameters. You just need to enter key/value pairs and Postman will encode the keys and values properly.
13、Note that you can not upload files through this encoding mode. There might be some confusion between form-data and urlencoded so make sure to check with your API first.这个编码是一样使用的URL 参数;你只需要输入键 / 值对,postman将编码键和值正常;请留意 , 您不能上传文件通过这个编码模式;可能会有一些混淆格式数据和urlencoded 所以肯定先检查你的API ;rawA raw request can conta
14、in anything. Postman doesnt touch the string entered in the raw editor except replacingenvironment variables. Whatever you put in the text area gets sent with the request. The raw editor lets you set the formatting type along with the correct header that you should send with the raw body. You can se
15、t theContent-Type header manually as well. Normally, you would be sending XML or JSON data here.原始恳求可以包含任何东西;postman 不碰在原始编辑器中输入的字符串取代环境变量除外;无论你的文本区域发送恳求;原始编辑器答应您设置格式类型以及正确的标题,你应当发送原始的身体;你也可以手动设置 content - type头;通常 ,你会在这里发送 XML 或 JSON数据;binarybinary data allows you to send things which you can not e
16、nter in Postman. For example, image, audio or video files. You can send text files as well. As mentioned earlier in the form-data section, you would have to reattach a file if you are loading a request through the history or the collection.二进制数据答应你发送的东西你不能进入postman ;例如 ,图像,音频或视频文件;您可以发送文本文件格式数据节;正如前
17、面提到的,你必需将一个文件加载恳求通过历史或集合;Working with responsesEnsuring that the API response is correct is something that you will be doing a lot. The Postman response viewer will make this task much easier for you.确保 API 的反应是正确的 , 你会做许多; postman 响应查看器将使这项任务变得更简洁;An API response consists of the body, headers and t
18、he status code. Postman organizes body and headers in different tabs. The status code with the time taken for the APIcall is displayed next to the tabs. You can hover over the status code to get more details about the code. Mostly it will be the default description as mandated by the spec but API au
19、thors can also add custom messages.API 的反应包括身体、头和状态码; postman 组织体在不同的标签和标题;时间的状态代码旁边的 API 调用显示选项卡;你可以悬停在状态代码更具体的代码;主要是它将默认 API 描述 标准强制要求的 , 但作者也可以添加自定义消息;Saving responsesIf a request has been saved in caollection, you can save responses for that request. Once the response has been received, click th
20、e Save response button. Youll be able to save the response with a name. All responses saved for a request will be available whenever you load the request above the request URL.假如恳求被储存在一个集合,您可以储存响应恳求;只有在接收到响应后, 单击 “储存响应 ”按钮; 你可以储存响应与一个名字;全部响应储存恳求可以无论何时加载恳求在恳求 URL ;Viewing responses-查看回复The Postman bo
21、dy tab gives you several tools to help you make sense of things quickly. The body can be viewed in one of three views - pretty, raw, and preview.postman 身体标签给你一些工具来帮忙您懂得事情很快;身体可以在三种观点美丽,生和预览PrettyThe pretty mode formats JSON or XML responses so that they are easier to look at. Nobody wants to scroll
22、 through a minified single line JSON response looking for that elusive string. Links inside the pretty mode are highlighted and clicking on them can load a GET request in Postman with the link URL. By clicking on the line numbers on the left you can fold large chunks of the response. For Postman to
23、automatically format the body, make sure the appropriate Content-Type header is returned. If the API does not do this then you can force formatting through JSON or XML. You can enable the Force JSON setting as well.美丽模式格式 JSON 或 XML 响应, 这样他们更简洁看; 没人想滚动一个缩小的单线JSON 响应查找难以捉摸的字符串 . 突出美丽的模式中的链接 , 点击可以加载一
24、个 GET 恳求的 postman 链接 URL;通过点击左边的行号你可以折叠大量响应; postman 自动格式 ,确保适当的内容类型返回头;假如API 不这样做 ,那么你可以迫使通过 JSON 或 XML 格式;您可以启用 “JSON力气 ”设置;Note: You can use Cmd+F / Ctrl+F to open the search bar, and Cmd+G / Ctrl+G to scroll through results.留意: 您可以使用 Cmd + F / Ctrl + F打开搜寻栏 ,和 Cmd + G / Ctrl + G滚动结果;RawThe raw v
25、iew is just a big text area with the response body. It can help to tell whetheryour response is minified or not.原始的观点只是一个大文本区域响应的身体;它可以帮忙你判定反应是否缩小;PreviewThe preview tab renders the response in a sandboxed iframe. Some web frameworks by default return HTML errors and the preview mode is especially h
26、elpful there. Due to iframe sandbox restrictions, Javascript and images are disabled in the iframe.preview 选项卡出现响应在沙箱iframe ;一些 web 框架默认返回HTML 错误和 preview 模式特别有帮忙;由于 iframe 沙箱限制 ,Javascript 和 iframe 图像被禁用;You can maximize the body to occupy the whole Postman window. In case, you plan on spending a l
27、ot of time with the response, this is the way to go.你可以最大化的身体占据整个 postman 窗口;在情形下 ,你方案花费了大量的时间和响应 , 这是路要走;If your API endpoint returns an image, Postman will detect and render it automatically. For binary response types, you should select Send and download which will let you save the response to you
28、r hard disk. You can then view it using the appropriate viewer. This gives you the flexibility to test audio files, PDFs, zip files or anything that the API throws at you.假如你的 API 端点返回一个形象 ,postman 将自动检测并出现它;对于二进制响应类型 ,你应当挑选 “发送和下载 ”会,让你节约硬盘的响应; 然后你可以查看它使用适当的观众; 这使您的敏捷性来测试音频文件 ,pdf,zip 文件或任何 API 抛给你
29、;HeadersHeaders are displayed as key/value pairs in the header tab. Hovering over the header name can give you a description of the header according to thespec. If you are sending a HEAD request, Postman will show the headers tab by default.标题显示的键 / 值对标题标签;徘徊在标题的名称可以给你描述标题依据标准;假如你发送 HEAD 恳求,postman
30、将显示默认标题标签;Basic AuthEnter the username and password fields and hit Refresh headers to generate the authorization header.输入用户名和密码字段 ,并点击 “刷新头 ”生成授权头;Digest AuthDigest auth is more complicated than basic auth and uses the values currently set in the request to generate the authorization header. Make s
31、ure they are set properlybefore you generate the header. Postman will remove the existing header if its already present.消化身份验证是更复杂的比基本认证和使用恳求中的值目前设置生成授权头;确保他们正确设置之前生成标题; postman 会删除现有的头假如它已经存在;OAuth 1.0aPostmans OAuth helper lets you sign requests which support OAuth 1.0a based authentication. Curre
32、ntly it does not let you acquire the access token. Thats something you would need from the API provider. The OAuth 1.0 helper can set values in either the header or as query parameters.Postman的 OAuth 助手让你签署恳求支持OAuth 1.0基础认证;目前它不让你猎取拜访令牌;这是需要从 API 供应者; OAuth 1.0助手可以在标题或设置值作为查询参数;As subsequent OAuth r
33、equests might expect a different nonce value, Postman can refresh the OAuth signature just before the request is sent if auto add parameters is enabled.后续的 OAuth 恳求可能认为不同 nonce 价值,postman 可以刷新 OAuth 签名发送恳求之前假如启用了自动添加参数;The OAuth 1.0 spec is quite complicated and there are many variations. Postman tr
34、ies to support as many of those variations as possible but if something does not work for you, please file an issue on Github. These are few of the options that weve included:OAuth 1.0 标准特别复杂 ,有许多变化; postman 试图支持尽可能多的这些变化,但假如不为你工作 ,请在Github 文件问题;这些都是一些我们的选项包括:.Add empty params to signature - Some im
35、plementationsof OAuth1.0require empty parameters to be added to the signature. 加空参数的签名 ,有些实现 OAuth1.0 需要添加到空参数签名;.Add params to header - If this is enabled, params are added to the header. If not - the URL params for a GET request, and the request body for POST/PUT requests参数添加到标题假如这是启用 ,参数被添加到标题;假如
36、不是一个 GET 恳求的 URL 参数, 和 POST 或 PUT恳求的恳求主体OAuth 2.0Postman supports getting the OAuth 2.0 token as well as adding it to requests really easy. To get an access token from an OAuth 2.0 provider, follow these steps:.Sets:/getpostman/oauth2/callbackas the callback URL in your app settings page.Get authori
37、zation URL, access token URL, client ID and client secret from your API provider. You can also set the Scope parameter which is needed by some APIs to set the level of access youhave within the API.Press the Get access token button to initate the OAuth2.0 flow. If everything is set up properly, you
38、would be redirected to the Postman server which will pick up your access token andsend it to the Postman app. To finish adding the token to Postman, give it a name so that you can access it quickly later.Access tokens are stored locally and will show up in the helper list. To add an access token to
39、the request, click the token name.Operations on folders/requestsEditingHover over the folder/request name in the sidebar, and click the edit pencil icon. This will allow you to change the name and description. Note that the description supports Markdown.DuplicatingDuplicating will create a copy of t
40、he folder/request. The new folder/request will be created as a sibling of the original.DeletingNote: Deleting a folder will delete its constituent requests, and deleting a request will delete any responses saved with the request.Sharing collectionsStarting with Postman v0.9.3 you have the ability to
41、 share and manage your collections more effectively. The first thing you will have to do is create a Postman account. You can create one using your email ID or a Google account. Once you are signed in after creating an account, the collections you upload on Postman are linked to your account. You ca
42、n delete them later through the Shared collections item in the navigation bar dropdown.从 postmanv0.9.3你有才能共享并更有效地治理你的集合;你要做的第一件事是创建一个postman 账户;您可以创建一个使用你的电子邮件ID 或一个谷歌帐户;一旦你在创建一个帐户后, 签署您上传的集合postman 都与您的帐户;稍后您可以删除它们通过导航栏中的“共享保藏 ”项下拉;The shared collections modal also lets you upload all of your local
43、 collections with one click. If you just installed Postman on a new machine, then you can download all your collections too.共享集合模态也让你上传全部的地方与一个点击保藏;假如你只是 postman 在新机器上安装 , 然后你也可以下载你全部的集合;Shared collections are private unless explicitly labelled public. You can download or delete individual collectio
44、ns too.共享集合是私有 ,除非显式标签;你也可以下载或删除个人保藏;API DirectoryThe Postman API directory gives you access to public collections shared by the Postman community. These are still early days for the directory but the goal is to have commonly used APIs available here. Developers should be able to get started quickly
45、 without having to recreate requests through the API documentation or curl docs.postmanAPI目录给你拜访公共集合由postman 共享社区;这些仍在早期的目录,但目标是常用的 API;开发人员应当能够开头快速而无需重新创建恳求通过API 文档或文档的旋度;This feature is currently available only in v0.9.xEnvironmentsWhile working with APIs, you will often need to have different set
46、ups. For example, your local machine, the development server, or the production API. Environments give you the ability to customize requests using variables. This way you can easily switch between different setups without changing your requests. You wont have to worry about remembering all those values once they are in Postman. Environments can be downloaded and saved as JSON files and uploaded later.使用 API 时, 您通常会需要不同的设置 , 例如,你的本地机器 , 开发服务器 ,或者生产 API ;环境使您能够定制恳求使用变量;这样你可以很简洁地切换不同的设置没有转变你的恳求;你不必担忧记住宅有这些值一旦postman ;环境中可以下载并储存为JSON 文件, 稍后上传;Each environment is a set of ke