1

This is my request:

http://localhost:8080/rest/object/number/24/render?rendering=%5BREAR%5D

(where %5BREAR%5D means [REAR], but the [] symbols needed to be escaped in Postman.)

In Karate, this is how far I got:

Scenario Outline: GET Render Object (Front and Rear)
    * header Authorization = $authHeader
    Given url $baseUrl
    And path "/object/number/" + "24" + "/render"
    And param rendering = <render>
    When method GET
    Then status 200
    And match header Content-Type == 'image/svg+xml'

    Examples:
    | render       |
    | %5BREAR%5D   |
    | '%5BREAR%5D' |
    | "%5BREAR%5D" |

None of the examples worked, it always results in 500 request response code. When checking the URL used by Karate for the request:

http://localhost:9999/rest/object/number/24/render?rendering=%255BREAR%255D

That means that my original parameter %5BREAR%5D was modified to %255BREAR%255D.

Does anyone know how to fix that, to have the results I have on Postman (i.e., 200 response)? Thank you in advance.

mixIrico
  • 37
  • 2
  • 1
    You said the brackets have to be escaped in Postman, but it looks like Karate is escaping those strings for you (%25 is the URL encoding for %). Can you try it with the actual brackets in your examples instead of %5? – samuei Aug 17 '23 at 14:34

1 Answers1

0

When you use param or path Karate will do the right thing for encoding, try this - and you can confirm it works because you can see what the server saw as the request (echoed in the response). You never know, if your server doesn't handle it - it can be considered a bug in your server implementation.

Scenario Outline:
  * url 'https://httpbin.org'
  * path 'anything'
  * param rendering = `[${render}]`
  * method get

  Examples:
  | render |
  | FOO    |
  | BAR    |

Note how Examples columns are auto-converted to proper variables.

Also refer similar questions: https://stackoverflow.com/a/59977660/143475

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248