Getting error http request failed: null when using path in karate

Gruutak :

I'm starting to use karate for testing, but when I use the "path" keyword, I receive a "http request failed: null" error.

When using the following scenario, it works:

Feature: items

Scenario: Testing /items response status
    Given url appBaseUrl + '/items'
    And param param1 = 1
    And param param2 = 10
    When method get
    Then status 200

But when I try using the "path" keyword like in the following code, I end up getting the error

Feature: items

Scenario: Testing /items response status
    Given url appBaseUrl
    And path 'items'
    And param param1 = 1
    And param param2 = 10
    When method get
    Then status 200
items.feature:8 - null
com.intuit.karate.exception.KarateException: items.feature:8 - null
    at ✽.When method GET (items.feature:8)

I can't figure out what I'm doing wrong. Is there some additional step that needs to be done and that I'm missing?

Peter Thomas :

There must be something else going on, because this should work. Try this for example:

* def appBaseUrl = 'http://httpbin.org/anything'

Given url appBaseUrl
And path 'items'
And param param1 = 1
And param param2 = 10
When method get
Then status 200

Works fine on my system.

So I suggest you follow this process: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

EDIT: this was indeed a bug: https://github.com/intuit/karate/issues/760 - and using karate-jersey is a workaround until the fix

Guess you like

Origin http://43.154.161.224:23101/article/api/json?id=157454&siteId=1