1

I read in the Karate documentation that if one uses "null", it will result in the key being omitted from the call. However, if one still wants to force a null, they could wrap it in parentheses like: "(null)".

It does go through with the key. However, on the actual call, the key is still omitted from the parameters. How can I force it there as well? Is it LITERALLY the same thing as an empty string?

I.e:

| Environment| Application| Version | status |
| Environment| Application| (null)  | 401    |
call read....

Results:

{
  "Environment": "Environment",
  "Application": "Application",
  "Version": "null",
  "status": 401
}

But the URL looks like:

GET https://?Environment=Environment&Application=Application

Please advise.

EDIT below for a better example:

In my "primary" file, I have the following:

* table requestTable
   | q      | um | ie  | status |
   | (null) | 1  | utf | 400    |

Where all three params (q, um, ie) are required parameters.

My "secondary" runner file, looks like the following:

* def requiredParams = { q: '#(q)', um: '#(um)', ie: '#(ie)'}
* def mainUrl = 'https://www.google.com'
* def apiPath = '/search'

Given url mainUrl
And path apiPath
And params requiredParams
When method GET
Then status 400

I am expecting a 400 since a required param is required. It doesn't get sent as "null", even if I use (null), it removes that field altogether in the actual call. This example obviously won't work in real life since I am using example google stuff. I apologize about that. If you still need a real life example, please show me how I can do it.

hungryhippos
  • 617
  • 4
  • 15

1 Answers1

0

I assume that you are talking about Examples: but your question is incomplete.

Try this: https://github.com/karatelabs/karate#scenario-outline-enhancements

Examples:
| Version! |
| ''       |
Peter Thomas
  • 54,465
  • 21
  • 84
  • 248
  • No sir, this isn't regarding scenario outlines but regular scenario and sending a value of "(null)" in a table. My Team Lead who has been working with Karate for much longer than I have, swears that a "null" value isn't the same thing as an empty string (as you allude to in your example above). So I was wondering how to send this elusive value of "null" without it omitting the key. – hungryhippos Oct 13 '21 at 05:07
  • @hungryhippos I'm lost. please edit your question so that it becomes a self-contained working example that I can cut and paste and try out. else follow this process: https://github.com/karatelabs/karate/wiki/How-to-Submit-an-Issue - I'll close this question after some time. – Peter Thomas Oct 13 '21 at 05:33
  • I edited the question. Sorry about the delay. Hope the clarification helps. – hungryhippos Oct 28 '21 at 15:06
  • @hungryhippos sorry, it made me more confused. kindly ask a new question and use this as a reference, see how it makes **real** calls: https://stackoverflow.com/a/69422451/143475 – Peter Thomas Oct 28 '21 at 15:25
  • Sorry about the confusion. I asked a new question here: https://stackoverflow.com/questions/69757737/using-null-still-omits-the-key-in-the-actual-get-call-need-to-find-a-way-to-s – hungryhippos Oct 28 '21 at 16:28