如何从Jason解析数据并在REST Url中填充 [英] How to parse data from jason and populate in REST Url

查看:38
本文介绍了如何从Jason解析数据并在REST Url中填充的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我无法从空手道中的json文件向Rest URL提供数据.我的特征文件结构如下:请帮忙.

I can't provide data from json file to Rest URL in karate. My feature file structure is as below; Please help out.

方案概述:获取答复

给出def data = read('classpath:JsonFilePath/data.json')

Given def data = read('classpath:JsonFilePath/data.json')

和def data1 = someJson.data [0] .data1

And def data1 = someJson.data[0].data1

和def data2 = someJson.data [0] .data2

And def data2 = someJson.data[0].data2

和路径=' https://myurl/account/#(data1)/phoneno/#(data2)/someoperationname '

方法获取时

然后状态成功

在这种情况下,我得到了无效的帐户和无效的phoneno错误,这意味着URL不能从json文件中获取数据.

In this case, I get invalid account and invalid phoneno error, which means the URL is not getting data from json file.

推荐答案

请参考文档:此外,您还混用了 url path 来参考文档.

Also you have mixed up url and path refer the docs for this also.

更改为:

And url 'https://myurl'
And path 'account', data1, 'phoneno', data2, 'someoperationname'

请注意如何用逗号分隔 path 并混合变量.

Note how path can be comma delimited and variables can be mixed.

我重复一遍-请仔细阅读文档和示例.

I repeat - please read the docs and examples carefully.

这篇关于如何从Jason解析数据并在REST Url中填充的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆