如何使用 Postman 使用 HTTP Basic 调用服务?如何使用、Postman、Basic、HTTP

2023-09-08 08:54:43 作者:傲忘天下

我正在使用 curl 发出请求:

I'm using curl to make a request:

curl -u NL91IOC2RWCM31G1ESWYX:SvCuj0tFQjmclZDFQzdMqfrGZ5Qw5jfKM8 
  -H "Accept: application/json" 
  https://api.stormpath.com/v1/applications/649j4AnLkUMezhYTl61

如何使用 Postman 发出同样的请求?

How do I make this same request using Postman?

推荐答案

curl -u key:secret 使用 HTTP Basic 身份验证发送请求.在 Postman 中很容易做到这一点:

curl -u key:secret sends a request with HTTP Basic authentication. It's easy to do this in Postman:

在地址字段中输入端点 URL.

切换到授权选项卡并选择基本身份验证.输入密钥作为用户名和密码作为密码.点击更新请求为请求生成正确的授权标头. Switch to the Authorization tab and choose Basic Auth. Enter the key as Username and the secret as Password. Click Update Request to generate the proper Authorization header for the request.

切换到 Headers 选项卡并添加 Accept 标题. Switch to the Headers tab and add the Accept header.

按发送.