Null values in JSON passed as { }
I have a JSON request I am sending, and it contains many keys with a null value. Somehow, during the transfer of this JSON to my request (or when it is sent), any null values are all magically switched over to { }, and I get a 400 error because the server is expecting literal nulls. I've tried looking and poking around and cannot find any kind of setting within SoapUI to prevent this.
There is a workaround in that the request still goes through if I remove any JSON nodes with a null value, the problem is that there's 180 of them, and that's kind of a hefty workaround for what I assume would be a simple task. Can anyone offer any insight into this?
TL;DR: My JSON request has many keys with a literal null value, but when the JSON is transferred to the request, all the nulls switch to { } and my request fails.
We actually managed to make it work, but we're not sure why it works this way and why it doesn't work the other way.
My transfer step actually has 3 transfers, in this order:
- requestJSON - The entire JSON request body (the one with all the nulls)
- reportId- Set to a specific node in requestJSON
- invoiceType - Also set to a specific node in requestJSON
Executing the request like this, all of the null values get switched to { }. However, when we move requestJSON to the bottom of the transfers (so the last one to get transferred), it keeps the nulls. For some reason the order of these property transfers affects the JSON. Is this a bug?
To get around this, we just used a Groovy script to inject the reportId and invoiceType directly into requestJSON, so we only need to transfer requestJSON instead of all 3.