1

I'm currently writing Automated REST API tests using Karate dsl and I'm encountering an issue when I try a kind of destructive test. Sending invalid query parameter.

I follow the recommendation from this post Karate: Query Param values are getting encoded who is to use the url only but it seems to not work with query parameter:

Scenario: Destructive testing - Illegal characters in parameters or payload
* def buildURL = 'http://127.0.0.1/identity/client?query={"idClient":{"$eq":9223372036854775807}}'
Given url buildURL
When method GET
Then status 400

error:

java.net.URISyntaxException: Illegal character in query at index 39: http://127.0.0.1/identity/client?query={"idClient":{"$eq":9223372036854775807}}

I have the same kind of test for url path where it works fine, but for query param, this way does not seems to work.

To be clear, my goal is to send query params or at least the character { without url encoding

Any idea to solve that ?

Thanks in advance

karate version : 0.9.6

  • 1
    Thanks for the quick response @Peter Thomas. I updated to 1.0.1. I also understand what I did when you said illegal characters according to the specification. I was confused because Postman allows to make this request and does not encode the brace and returns a 400 without a body but now I understand that it is just not allowed. Thanks again and thank you for the great work you do arround karate – Paulywebster Apr 26 '21 at 18:29

1 Answers1

0

First, you are trying illegal characters as per the spec, so you may need to manually "URL-encode" the URL - and you already seem to be aware of all this, based on the link in your question. Maybe your server is not compliant with the spec.

Recommend you try upgrading to 1.0 and also refer this open issue: https://github.com/intuit/karate/issues/1561

Anything beyond this will require you to help / contribute code.

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