我有一个场景:
调用 API - 捕获响应 - 从响应中获取 ID 并调用另一个 API,该 API 从响应 1 中获取输入 ID。
Ex :
Feature: test graphql end point
Background:
* url baseUrl + '/graphql'
Scenario: Create Org Call
Given text query =
"""
mutation {
test: createOrganization(
name: "Org Name"
)
{
Id
name
}
}
"""
And request { query: '#(query)' }
When method post
Then status 200
* def res = response
* def id = res.data.test.Id
* print 'response:', response
* print 'Id:', id
Given text query =
"""
mutation {
createBackendHistory(orgId: '#(id)') {
orgId
}
}
"""
And request { query: '#(query)' }
When method post
Then status 200
如何传递值(来自调用1的Id)是createBackendHistory API
当我尝试 orgId: '#(id)' 时出现错误。
Since query
is text
你不能使用#()
嵌入表达式。请参考文档:https://github.com/intuit/karate#replace
尝试这个:
Given text query =
"""
mutation {
createBackendHistory(orgId: '<id>') {
orgId
}
}
"""
And replace query.id = id
And request { query: '#(query)' }
When method post
Then status 200
本文内容由网友自发贡献,版权归原作者所有,本站不承担相应法律责任。如您发现有涉嫌抄袭侵权的内容,请联系:hwhale#tublm.com(使用前将#替换为@)