使用Postman实现Azure REST API全攻略

时间:2021-07-15 | 标签: | 作者:Q8 | 来源:Kumar Allamraju网络

小提示:您能找到这篇{使用Postman实现Azure REST API全攻略}绝对不是偶然,我们能帮您找到潜在客户,解决您的困扰。如果您对本页介绍的使用Postman实现Azure REST API全攻略内容感兴趣,有相关需求意向欢迎拨打我们的服务热线,或留言咨询,我们将第一时间联系您!

< ">作为一款API集成测试的强大工具,Postman广泛应用于包含持久化数据和系统用户交互模拟等场景中,以获得可重用和可靠的测试结果。本文将详细解读如何使用Postman进行REST API的测试及验证。

< font-size: 16px;">首先,下载并安装适用操作系统的Postman原生应用:https://www.getpostman.com/downloads/

< font-size: 16px;">启动Postman应用程序并创建相应的新环境。在本文示例中,笔者将其命名为“azuretips”。

< font-size: 16px;">如需了解更多关于创建环境的信息,可参考此链接:

< font-size: 16px;">https://learning.getpostman.com/docs/postman/environments_and_globals/manage_environments/

< font-size: 16px;">从Azure Cloud Shell中创建一个service principal。这种情况下用户无需在本机中安装Azure CLI。

< font-size: 16px;">az ad sp create-for-rbac-n"your service principal name"

< font-size: 16px;">e.g.az ad sp create-for-rbac-n"azuretips"

< font-size: 16px;">Creating a role assignment under the scope of"/subscriptions/11389280-b2a2-***********"

< font-size: 16px;">  Retrying role assignment creation:1/36

< font-size: 16px;">  Retrying role assignment creation:2/36

< font-size: 16px;">  Retry推广笔记ing role assignment creation:3/36

< font-size: 16px;">{

< font-size: 16px;">  "appId":"d2846107-f7ae-439b-8a16-da440d52e950",

< font-size: 16px;">  "displayName":"azuretips",

< font-size: 16px;">  "name":"https://azuretips",

< font-size: 16px;">"password":"00593485-8bda-4c2b-8c4e-2ab52241c24c",

< font-size: 16px;">"tenant":"72f98xxx-86f1-41af-****"

< font-size: 16px;">}

< font-size: 16px;">在cloud shell中执行以下命令以获取Azure订阅ID

< font-size: 16px;">az account show--query id

< font-size: 16px;">"11389280-b2a2-4183-b757-xxxxxx"

< font-size: 16px;">在Postman的“azuretips”环境部分输入第二步创建的tenantid(租户)、clientid(appId)、clientsecret(密码)和subid(订阅ID)。详情可参考下方截图:

< font-size: 16px;">

< font-size: 16px;">在Postman应用程序中创建一个新的收藏夹,将所有REST调用存储在隔离的分区中。

< font-size: 16px;">如需了解更多关于Postman收藏夹的信息,可参考:https://learning.getpostman.com/docs/postman/launching_postman/creating_the_first_collection/

< font-size: 16px;">在执行任何Azure REST API调用前,用户须获取承载令牌(bearer token)。

< font-size: 16px;">发出POST请求https://login.microsoftonline.com/:tenantid/oauth2/token

< font-size: 16px;">详细信息如下

< font-size: 16px;">-Params Tab&gt;&gt;Path Variables.

< font-size: 16px;">Key:tenantid

< font-size: 16px;">Value:{{tenantid}}

< font-size: 16px;">-Authroization Tab

< font-size: 16px;">Type:Inherit auth from parent



< font-size: 16px;">-Headers Tab

< font-size: 16px;">Content-Type:application/x-www-form-urlencoded

< font-size: 16px;">-Body tab

< font-size: 16px;">grant_type:client_credentials

< font-size: 16px;">client_id:{{clientid}}

< font-size: 16px;">client_secret:{{clientse引流工具有哪些cret}}

< font-size: 16px;">resource:https://management.azure.com/

< font-size: 16px;">-following value in the Tests tab

< font-size: 16px;">pm.environment.set("bearerToken",pm.response.json().access_token);

< font-size: 16px;">

< font-size: 16px;">

< font-size: 16px;">有些用户可能认为这些步骤工作量巨大,但其实只需要在Postman中设置一次。用户可以与其他工作伙伴共享、再利用或复制此环境。



< font-size: 16px;">获取承载令牌(bearer token)后,可执行Azure REST API以获取资源组(Resource Groups)、某一特定资源组详情和虚拟网络(VNet)等信息。

< font-size: 16px;">举个例子,用户为获取Azure订阅中的资源组详细信息而发出GET请求,如图所示:

< font-size: 16px;">

< font-size: 16px;">如需使用正确的GET或POST请求调用Azure REST API可点击此链接了解详情:

< font-size: 16px;">Azure REST APIs:https://docs.microsoft.com/en-us/rest/api/?view=Azure

< font-size: 16px;">小结



< font-size: 16px;">Postman是一款全面的API测试工具,能够轻松设置自动测试。用户可以将创建的测试和请求集成到单个自动化测试序列中。Postman是唯一完整提供单一事实来源[1]的API开发和测试环境。在本文中笔者详细介绍了利用Azure REST APIs使用Postman的方式。

< font-size: 16px;">Postman:https://www.getpostman.com/automated-testing?_ga=2.53476456.151619731.1566574042-329050526.1563821057

< font-size: 16px;">Azure REST APIs:https://docs.microsoft.com/en-us/rest/api/?view=Azure

< font-size: 16px;">译者注

< font-size: 16px;">单一事实来源,即SSOT(single source of truth),通过构建信息模型和相关数据架构,从而根据单一位置掌握(或编辑)系统中的每个数据元素。用户只需引用此数据元素的关联信息,该信息可能位于关系架构的某个区域,甚至可能位于遥远的联合数据库中。由于数据的所有其他位置仅引用主“事实来源”位置,主位置中数据元素的更新将传播到整个系统,且不会遗忘某个位置的重复值。

使用Postman实现Azure REST API全攻略

上一篇:关于Wish店铺选品工具物托帮votobo的介绍
下一篇:社交巨头:Twitter与Facebook不同的商业模式


版权声明:以上主题为“使用Postman实现Azure REST API全攻略"的内容可能是本站网友自行发布,或者来至于网络。如有侵权欢迎联系我们客服QQ处理,谢谢。
相关内容
推荐内容
扫码咨询
    使用Postman实现Azure REST API全攻略
    打开微信扫码或长按识别二维码

小提示:您应该对本页介绍的“使用Postman实现Azure REST API全攻略”相关内容感兴趣,若您有相关需求欢迎拨打我们的服务热线或留言咨询,我们尽快与您联系沟通使用Postman实现Azure REST API全攻略的相关事宜。

关键词:使用Postman实现Azure,REST,A

关于 | 业务 | 案例 | 免责 | 隐私
客服邮箱:sales@1330.com.cn
电话:400-021-1330 | 客服QQ:865612759
沪ICP备12034177号 | 沪公网安备31010702002418号