Saurabh
Saurabh

Reputation: 940

Karate API Tests - Escaping '?' in the url in a feature file

I am using the path keyword from Karate API framework to concatenate strings to form a url. However, I am not able to pass '?'. Here is what I am doing:

 Background: 
    * url 'https://api.cloud.abcde.com/animal/'

 Scenario: Verify the get status
    Given path 'herbivore?id=25'
    When method get
    Then status 200

When I run the test, i see the '?' being passed as %3F. I tried to escape it using \ and tried some other answers too but couldn't succeed. Do I need to use url encoding ? Any pointers or help would be appreciated. Thanks

Upvotes: 3

Views: 4043

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

You should use param for this case:

Scenario: Verify the get status
    Given path 'herbivore'
    And param id = 25
    When method get
    Then status 200

Upvotes: 6

Related Questions