rest - 在 BAT CLI for Mulesoft 的 API URL 中注入自定义值
问题描述
我在 Mulesoft 中使用 BAT CLI 编写功能 API 测试 - https://docs.mulesoft.com/api-functional-monitoring/bat-bdd-reference。
我正在尝试将 URL 中 API 调用响应中获得的值用于另一个后续 API 调用。
import * from bat::BDD
import * from bat::Assertions
import * from bat::Mutable
var context = HashMap()
---
it ("capture a value from a API response") in [
GET https://first.api.call/abc,
execute [
// This works
context.set('myVal',$.response.body.myVal)
]
],
it ("use the value in the second API URL") in [
// I am trying to inject the value obtained above in the URL below
GET https://first.api.call/{context.get('myVal')}
....
]
显然我没有得到正确的语法。{context.get('myVal')}
不起作用。我也试过了$({context.get('myVal')})
,$(context.get('myVal'))
也不行。
谁能说出正确的语法是什么?
解决方案
这有效:
GET https://first.api.call/$(context.get('myVal'))
干杯!
推荐阅读
- c# - 使用 C# 将给定 URL 的 XML 文件加载到 Visual Studio
- php - PHP 将一个 $ 数量的数组映射到一个变量数组,并将变量乘以它的正确数量
- excel - 使用 microsoft-graph excel API 刷新 excel powerquery
- c# - ASP.NET 唯一浏览器 ID
- temp-tables - 临时表存储在 GreenPlum 数据库中的什么位置?
- python - 在派对加载的数据上训练 Keras 模型
- c# - 我应该使用 System.Net.Http Nuget 包吗?
- jestjs - 测试失败并显示消息“OTransitionProperty”
- sql - 默认缺失数据
- javascript - 你如何处理小数(,)和javascript?