Closed
Description
When modifyUris() is used, the URL data in the request body is wrong converted, and PayloadHandlingException is thrown.
[Fatal Error] :1:1: Content is not allowed in prolog.
Cannot handle application/json content as it could not be parsed as JSON or XML
org.springframework.restdocs.payload.PayloadHandlingException: Cannot handle application/json content as it could not be parsed as JSON or XML
at app//org.springframework.restdocs.payload.ContentHandler.forContentWithDescriptors(ContentHandler.java:69)
at app//org.springframework.restdocs.payload.AbstractFieldsSnippet.createModel(AbstractFieldsSnippet.java:157)
at app//org.springframework.restdocs.snippet.TemplatedSnippet.document(TemplatedSnippet.java:78)
at app//org.springframework.restdocs.generate.RestDocumentationGenerator.handle(RestDocumentationGenerator.java:191)
at app//org.springframework.restdocs.mockmvc.RestDocumentationResultHandler$1.handle(RestDocumentationResultHandler.java:77)
my preprocessRequest config
String host = "dev-sample.sample.com"
preprocessRequest(
prettyPrint(),
modifyUris().scheme("https").host(host).removePort()
)
my requestbody data
{
"name": "sample",
"bannerImageFile": {
"fileId": 1,
"name": "image.png",
"mimeType": "image/png",
"size": 1024
"linkUrl": "https://dev-test.test.com"
},
"targetUserFile": {
"fileId": 2,
"name": "example.csv",
"mimeType": "text/csv",
"size": 1024,
"linkUrl": ""
}
}
requestbody data after modifyUris()
{
"name": "sample",
"bannerImageFile" : {
"fileId" : 1,
"name": "image.png",
"mimeType": "image/png",
"size" : 1024,
"uploadStatus" : 2,
"linkUrl" : "https://dev-sample.sample.com: {
"fileId" : 2,
"name" : "example.csv",
"mimeType" : "text/csv",
"size" : 1024,
"linkUrl" : ""
}
}
I want the modifyUris() setting to only apply to the host part and not to the request body data.