1

When I pass a JSON request starting with [, I get the error which says: invalid request format with GET operation.

Here is my request. The same works fine in PostMan.

[
  {
    "equipmentNumber": "76576",
    "systemIdentifier": "00045F063547",
    "serialNumber": "00098",
    "materialNumber": "786786"
  }
]
sɐunıɔןɐqɐp
  • 3,332
  • 15
  • 36
  • 40

1 Answers1

1

Your question is incomplete. Anyway I'll give it a shot. Here is a test that works perfectly fine in Karate, cut and paste it into a new Scenario and see for yourself.

* url 'https://httpbin.org/post'
* request 
"""
[
  {
    "equipmentNumber": "76576",
    "systemIdentifier": "00045F063547",
    "serialNumber": "00098",
    "materialNumber": "786786"
  }
]
"""
* method post

Which results in this request:

1 > POST https://httpbin.org/post
1 > Accept-Encoding: gzip,deflate
1 > Connection: Keep-Alive
1 > Content-Length: 112
1 > Content-Type: application/json; charset=UTF-8
1 > Host: httpbin.org
1 > User-Agent: Apache-HttpClient/4.5.5 (Java/1.8.0_231)
[{"equipmentNumber":"76576","systemIdentifier":"00045F063547","serialNumber":"00098","materialNumber":"786786"}]

So if you are still stuck, follow this process - else no one can help you with the lack of information in your question: https://github.com/intuit/karate/wiki/How-to-Submit-an-Issue

Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • This didnt work. I need it in GET Method, its not working in GET method. error is cannot convert to map. This is the error: cannot convert to map: [{"equipmentNumber": "76576","systemIdentifier": "00045F063547","serialNumber": "00098","materialNumber": "786786"}] – Bhargava Mandya Dec 14 '19 at 15:19
  • @BhargavaMandya you can't use a `request` body for a GET, it is against the spec: https://stackoverflow.com/a/983458/143475 - Karate will never support it - so either change your server side code or use Postman itself or another tool. If you want to do a "negative test" please don't do it for such cases, it is a waste of time – Peter Thomas Dec 14 '19 at 15:21
  • No, this is a positive use case. i am trying with params and its failing with error cannot convert to map: [{"equipmentNumber": "76576","systemIdentifier": "00045F063547","serialNumber": "00098","materialNumber": "786786"}] – Bhargava Mandya Dec 14 '19 at 15:23
  • @BhargavaMandya I have nothing else to add. Your question is incomplete. Maybe you mean `param` - but who knows: https://github.com/intuit/karate#param - maybe someone else has the patience to help you - else follow the instructions in my answer – Peter Thomas Dec 14 '19 at 15:26
  • I have a request and i am trying the GET Operation from karate and when i do so with the request, the request body comes as null. So there is no way we can do get operation with request body in karate? This is my request [{"equipmentNumber": "76576","systemIdentifier": "00045F063547","serialNumber": "00098","materialNumber": "786786"}] – Bhargava Mandya Dec 14 '19 at 15:35