是否可以使用相同的值动态更改json数据后面的URL

xzv2uavs  于 2022-11-26  发布在  其他
关注(0)|答案(1)|浏览(104)
Background: 
    * url 'yyy'
    And header Authorization = 'xxxxx

  Scenario: read the csv file
    Given url 'xxxx'
    And multipart file importfile = {read:'datasets/zzzz.csv'}
    And multipart file entity = 'contact'
    When method POST
    And print response
    Then status 201
    * def importid = response.data.import_id
    Then print **importid** **replacing this importid in the below url. this changes dynamically**

指定的网址为'https://' +导入标识符+ '/preview'

* def body =
      """
      {
      "import_id": "importid", **replacing here with the values from importid dynamically**
      "entity_columns": [

两个URL中的导入ID应替换为JSON字符串

背景说明:
场景:

* def importid = response.data.import_id
    Then print **importid**

指定的网址为'https://' +导入标识符+ '/preview'

* def body =
      """
      {
      "import_id": "<importid>", **replacing here with the values from importid dynamically**
      "entity_columns": [
h79rfbju

h79rfbju1#

我认为你真的需要花一些时间阅读文档。无论如何,试试这个简单的例子:

* url 'https://httpbin.org/get'
* param foo = 'bar'
* method get

* def id = response.args.foo

* url 'https://httpbin.org/anything/' + id
* request { id: '#(id)' }
* method post

请注意id是如何从第一个响应派生出来的,以及如何在POST请求的第二个URL和JSON主体中使用。

相关问题