1

Simple POST method is not working in Karate API, which works fine in POSTMAN, getting error as below

ERROR com.intuit.karate - java.net.ConnectException: Connection refused: connect, http call failed after 1101 milliseconds for URL: https://api.stripe.com/v1/customers

It works fine in POSTMAN and browser 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
Vivek Sr
  • 21
  • 4

1 Answers1

1

You haven't read the documentation and you did not realize this is an HTML form submit. The Content-Type should have given you a hint. Here is your solution:

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
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248