使用 Postman 测试 Azure 应用程序配置 REST APITest the Azure App Configuration REST API using Postman
若要使用 Postman 测试 REST API,需要在请求中包含身份验证所需的 HTTP 标头。To test the REST API using Postman, you'll need to include the HTTP headers required for authentication in your requests. 下面介绍如何配置 Postman 来测试 REST API,并自动生成身份验证标头:Here's how to configure Postman for testing the REST API, generating the authentication headers automatically:
将 JavaScript 身份验证示例中的
signRequest
函数添加到请求的预请求脚本中Add thesignRequest
function from the JavaScript authentication sample to the pre-request script for the request将以下代码添加到预请求脚本的末尾。Add the following code to the end of the pre-request script. 按 TODO 注释所示更新访问密钥Update the access key as indicated by the TODO comment
// TODO: Replace the following placeholders with your access key var credential = "<Credential>"; // Id var secret = "<Secret>"; // Value var isBodyEmpty = pm.request.body === null || pm.request.body === undefined || pm.request.body.isEmpty(); var headers = signRequest( pm.request.url.getHost(), pm.request.method, pm.request.url.getPathWithQuery(), isBodyEmpty ? undefined : pm.request.body.toString(), credential, secret); // Add headers to the request headers.forEach(header => { pm.request.headers.upsert({key: header.name, value: header.value}); })
发送请求Send the request