3

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

Saurabh
  • 930
  • 2
  • 17
  • 39

1 Answers1

6

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
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • I am getting error Step param id doesn't have a matching glue code. – Saurabh Aug 01 '17 at 15:07
  • 1
    @Saurabh there must be some other problem. Here is an example you can refer to: https://github.com/intuit/karate/blob/master/karate-demo/src/test/java/demo/greeting/greeting.feature – Peter Thomas Aug 01 '17 at 15:11
  • 1
    Thanks that helped. – Saurabh Aug 01 '17 at 15:17
  • 2
    If you are having @Saurabh's error remember to leave spaces between your query param name, the equality operator and the value. E.g. id=25 will fail. id = 25 is the right way. – pkanane May 07 '19 at 09:56