Hello Can someone help me with this issue? <https:...
# help
n
Hello Can someone help me with this issue? https://github.com/mobileforming/WiremockClient/issues/39 Text from the issue:
Hello,
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:
Copy code
(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
version: 3.0.0 client: iOS
o
IIUC the issue, a patch of https://github.com/mobileforming/WiremockClient is needed
n
Yes. We added:
Copy code
urlRequest.setValue("application/json", forHTTPHeaderField: "Content-Type")
And it works