Nodir Musaev
05/30/2023, 7:59 AMHello,
By default the .postMapping method creates a stub using an URLRequest with a default Content-Type “application/x-www-form-urlencoded”, which is incorrect. The value of this header should be “application/json” since the body is actually JSON.
I am having an issue where a security equipment between my client code and the mock server blocks all stub creations because of the incorrect value of this HTTP Header.
I tested that the correct value “application/json” works as intended.
Do you think it would be possible to use the correct value for all stub creations please ?
Thank you for your help.
(If you need, I can provide a PR)We are facing same problem. In response data we printed result:
(lldb) po String(data: data!, encoding: .utf8)
▿ Optional<String>
- some : "{\n \"errors\" : [ {\n \"code\" : 10,\n \"source\" : { },\n \"title\" : \"Error parsing JSON\",\n \"detail\" : \"Unexpected character (\'%\' (code 37)): expected a valid value (JSON String, Number, Array, Object or token \'null\', \'true\' or \'false\')\\n at [Source: (String)\\\"... more response data code here
Oleg Nenashev
05/30/2023, 8:41 AMNodir Musaev
05/30/2023, 8:56 AMurlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
And it works