首页 > 解决方案 > 如何设置基本 API?我看到从第一个 API 的响应中添加了双引号

问题描述

Given path '/api/metrics/product/ABC'
When method get
   * def id = get response
   * print id
   * def basePathProducts = '/another/api/' + id + '/param'   
  Given path basePathProducts
  When method GET
  Then status 200

12:59:28.447 [main] INFO com.intuit.karate.StepDefs - [print] "5ca627bf3edd851238e59c9e" 2019 年 4 月 16 日 12:59:28 PM org.glassfish.jersey.logging.LoggingInterceptor 日志严重:2 * 发送客户端请求在主线程 2 > GET

http://localhost:8080/API/ANOTHER/API/%225ca627bf3edd851238e59c9e%22/PARAM

标签: karate

解决方案


你的帖子真的很难理解。

尝试使用

Given url yourURLVariable + 'another/api/'+ id + '/param'

有关更多信息,请参阅此:https ://stackoverflow.com/a/54477346/10791639

编辑:您的参数有问题。

* def id = "5ca627bf3edd851238e59c9e"
* print id

给出:

13:24:19.783 [print] 5ca627bf3edd851238e59c9e

所以你的变量id"5ca627bf3edd851238e59c9e"5ca627bf3edd851238e59c9e


推荐阅读