【问题标题】:Karate API : How to hit an endpoint url with post method which does not have request body空手道 API:如何使用没有请求正文的 post 方法访问端点 url
【发布时间】:2019-03-12 21:08:27
【问题描述】:

当我尝试使用没有正文的 post 方法访问端点 url 时,我遇到了错误。在邮递员中,我可以使用没有正文的 post 方法访问端点 url。我通过参考空手道 API 文档尝试了所有步骤。

 **Error** : com.intuit.karate.exception.KarateException: TestScenarios.feature:56 - 
request  body is required for a POST, please use the 'request' keyword

testurl 是:

 **test-api.test.com/test-com/api/check/initiate? 
lang=en&cntCode=us&id=8d1b9355**

尝试 1:

Given url 'test-api.test.com/test-com/api/check/initiate?lang=en&cntCode=us&id=8d1b9355'
When method post
Then status 200
* print  response

尝试 2:

Given url testurl
And param lang= en
And param cCode = us
And param id= '8d1b9355'
When method post
* print 'Response'+response

尝试3:

Given url testurl
And form field lang= en
And form field cCode = us
When method post
Then status 200

有人可以帮助我理解我的方法中的问题和错误。

【问题讨论】:

  • 是的...最后我自己找到了解决方案。我应该像 And request {} 一样将请求正文作为空传递。早些时候我尝试了空请求,但带有 () 括号而不是 {}
  • 无论如何都已经回答了以帮助其他人

标签: karate


【解决方案1】:

两个可能的选项取决于您的服务器:

* request {}

as per the docs:

* request ''

【讨论】:

    猜你喜欢
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2022-01-13
    • 1970-01-01
    • 1970-01-01
    • 1970-01-01
    • 2019-12-06
    相关资源
    最近更新 更多