简单的 POST 请求在空手道 API 中不起作用,在 POSTMAN 中同样可以正常工作,请在'request'中提出任何错误



简单的帖子方法在空手道API中不起作用,在Postman中工作正常,在下面获取错误

错误com.intuit.karate -java.net.connectException:连接拒绝:连接,http呼叫在1101毫秒之后失败:https://api.stripe.com/v1/customers

它在邮递员和浏览器中正常工作URL:https://api.stripe.com/v1/customers

I tried with karate-apache / karate-jersey
Feature: Pharmacies Get Default City Code
  Background:
    * url pharmaciesUrl
  @GetPharmaciesByDefaultCity
  Scenario: Create New Customers
    Given url pharmaciesUrl
    And header Content-Type = 'application/x-www-form-urlencoded'
    And header Authorization = 'Bearer sk_test_Y566a568oL0lbYwRurOvJ4g6'
    Then request {"email": "test1@test.com", "name": "vivek", "description": "Test"}
    When method POST
    Then status 200
    And match response == {id: '#notnull', name: 'vivek'}
Expected: It should create customer with post request which I am passing with status code 200
Actual: Getting below error
09:25:07.278 [main] ERROR com.intuit.karate - java.net.ConnectException: Connection refused: connect, http call failed after 1101 milliseconds for URL: https://api.stripe.com/v1/customers
09:25:07.279 [main] ERROR com.intuit.karate - http request failed: 
java.net.ConnectException: Connection refused: connect
pharmacies.feature:12 -`enter code here`
java.net.ConnectException: Connection refused: connect

您尚未阅读文档,也没有意识到这是HTML表单提交。Content-Type应该给您一个提示。这是您的解决方案:

Given url 'https://api.stripe.com/v1/customers'
And header Authorization = 'Bearer sk_test_Y566a568oL0lbYwRurOvJ4g6'
And form field email = 'test1@test.com'
And form field name = 'vivek'
And form field description = 'Test'
When method post
Then status 200

相关内容

最新更新