【问题标题】:Simple POST request is not working in Karate API, same will work fine in POSTMAN, please suggest anything wrong in 'request' [duplicate]简单的 POST 请求在空手道 API 中不起作用,在 POSTMAN 中也可以正常工作,请在“请求”中提出任何错误 [重复]
【发布时间】:2019-11-18 23:12:07
【问题描述】:

简单的 POST 方法在 Karate API 中不起作用,在 POSTMAN 中可以正常工作, 出现如下错误

错误 com.intuit.karate - java.net.ConnectException:连接被拒绝:连接,http 调用在 1101 毫秒后失败,网址为:https://api.stripe.com/v1/customers

在 POSTMAN 和浏览器中运行良好 网址: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

【问题讨论】:

    标签: karate


    【解决方案1】:

    您没有阅读文档,也没有意识到这是一个 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
    

    【讨论】:

      猜你喜欢
      • 2023-04-06
      • 1970-01-01
      • 2018-03-04
      • 2018-06-10
      • 2021-10-05
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      相关资源
      最近更新 更多