Rishim
Rishim

Reputation: 53

Karate not allowing invalid Json syntax

I am using a json request and as part of negative testing, I am making it as invalid as below. I have removed the comma at the end of plancode line and I am expecting this request to go to server and show the error response from server.The problem is it is giving me syntax error in Karate as

net.minidev.json.parser.ParseException: Unexpected token "

It is working fine through SOAP UI. Need help here !

def user =

{
"requesterID": "test1",
"clientTraceLevel": 4,
"application": "ABC",
"planCode": "newcode"
"planEffDate":"12/3/2018",
"status": "b"
}

Upvotes: 1

Views: 1539

Answers (1)

Peter Thomas
Peter Thomas

Reputation: 58058

You can use the text data type:

* text user =
"""
{
"requesterID": "test1",
"clientTraceLevel": 4,
"application": "ABC",
"planCode": "newcode"
"planEffDate":"12/3/2018",
"status": "b"
}
"""

Note that you may need to force the right Content-Type header in this case, please read the docs on how to do so.

Upvotes: 1

Related Questions