Karate API – 无法在路径中传递变量值

huangapple go评论63阅读模式
英文:

Karate API - Could not pass the variable value in the path

问题

我正在尝试传递AppraisalID的变量值,但它没有被识别。请帮忙。

    给定路径'/products/propertyedge/appraisal'
        并且请求'{ "valuationId":"372629" }'
        当方法为Post
        那么状态为201
        * 定义 location = responseHeaders['Location'][0]
        * 定义 appraisalId = location.substring(location.lastIndexOf('/') + 1)
        * 输出 appraisalId
        给定路径 'products/propertyedge/appraisal/{appraisalId}'
        并且参数 action = 'view'
        当方法为Get
        那么状态为200
        并且断言 response.appraisalId == <appraisalId>

响应:
Karate API – 无法在路径中传递变量值

#karate #api

尝试使用场景大纲变量<>, 但没有成功。请帮忙。

英文:

I am trying to pass the variable value of AppraisalID but it is not recognized. Please help

Given path &#39;/products/propertyedge/appraisal&#39;
    And request &#39;{&quot;valuationId&quot;:&quot;372629&quot;}&#39;
    When method Post
    Then status 201
    * def location = responseHeaders[&#39;Location&#39;][0]
    * def appraisalId = location.substring(location.lastIndexOf(&#39;/&#39;) + 1)
    * print appraisalId
    Given path &#39;products/propertyedge/appraisal/{appraisalId}&#39;
    And param action = &#39;view&#39;
    When method Get
    Then status 200
    And assert response.appraisalId == &lt;appraisalId&gt;

Response:
Karate API – 无法在路径中传递变量值

#karate #api

Tried with scenario outline variable <> but in vain. Please help

答案1

得分: 1

给定路径 'products/propertyedge/appraisal', appraisalId.

英文:

Please read the docs: https://github.com/karatelabs/karate#path

Given path &#39;products/propertyedge/appraisal&#39;, appraisalId

huangapple
  • 本文由 发表于 2023年3月23日 09:08:55
  • 转载请务必保留本文链接:https://go.coder-hub.com/75818487.html
匿名

发表评论

匿名网友

:?: :razz: :sad: :evil: :!: :smile: :oops: :grin: :eek: :shock: :???: :cool: :lol: :mad: :twisted: :roll: :wink: :idea: :arrow: :neutral: :cry: :mrgreen:

确定