ClassCastException Thrown when referring json file in request body with content type "multipart/form-data"
See original GitHub issueIssue:
With content-type:"multipart/form-data"
getting java.lang.ClassCastException
when referring json
file for additional payload in Request Body apart from "files": [ "file:media/test.wav" ]
Request step:
{
"name": "save_config",
"url": "/config",
"operation": "POST",
"request": {
"headers": "${JSON.FILE:standard_headers_media.json}",
"body": {
"files": [
"file:media/test.wav"
],
"metadata": "${JSON.FILE:metadata.json}"
}
},
"assertions": {
"status": 201,
"headers": {
"${correlationId.header}": "$NOT.NULL"
}
}
}
metadata.json
{
"name": "name",
"fileName": "test.wav",
"location": "location",
}
standard_headers_media.json:
{
"Content-Type": "multipart/form-data"
}
Error:
java.lang.RuntimeException: java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class java.lang.String
(java.util.LinkedHashMap and java.lang.String are in module java.base of loader 'bootstrap')
Stactrace:
Caused by: java.lang.ClassCastException: class java.util.LinkedHashMap cannot be cast to class java.lang.String
(java.util.LinkedHashMap and java.lang.String are in module java.base of loader 'bootstrap')
at org.jsmart.zerocode.core.httpclient.utils.FileUploadUtils.buildOtherRequestParams(FileUploadUtils.java:60)
at org.jsmart.zerocode.core.httpclient.BasicHttpClient.createFileUploadRequestBuilder(BasicHttpClient.java:356)
at org.jsmart.zerocode.core.httpclient.BasicHttpClient.createRequestBuilder(BasicHttpClient.java:400)
at org.jsmart.zerocode.core.httpclient.BasicHttpClient.execute(BasicHttpClient.java:126)
at org.jsmart.zerocode.core.engine.executor.JsonServiceExecutorImpl.executeRESTInternal(JsonServiceExecutorImpl.java:131)
at org.jsmart.zerocode.core.engine.executor.JsonServiceExecutorImpl.executeRESTService(JsonServiceExecutorImpl.java:92)
Issue Analytics
- State:
- Created 3 years ago
- Comments:7 (3 by maintainers)
Top Results From Across the Web
Spring Boot controller - Upload Multipart and JSON to DTO
Your endpoint takes only one param, which is file and of type multipart form data. Mine is a combinatio of json and multipart....
Read more >java.lang.String cannot be cast to com.vordel.mime.Body
Resolution. The class com.vordel.mime.Body has several different sub-types that reference different types of content, so it will break ...
Read more >Fix list for IBM WebSphere Application Server V8.5
The following is a complete listing of fixes for V8.5 with the most recent fix at the top. Content. Back to all versions ......
Read more >Apache Tomcat 8 (8.5.84) - Changelog
#550: Correctly handle case where a Servlet responds to a request with an expectation with a 2xx response without reading the request body....
Read more >ryanwu/rn-fetch-blob - Gitee
Upload a file from storage; Multipart/form-data example: Post form data with file and ... When the body is an Array we will set...
Read more >Top Related Medium Post
No results found
Top Related StackOverflow Question
No results found
Troubleshoot Live Code
Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start FreeTop Related Reddit Thread
No results found
Top Related Hackernoon Post
No results found
Top Related Tweet
No results found
Top Related Dev.to Post
No results found
Top Related Hashnode Post
No results found
Top GitHub Comments
Forked the repo, started working on this. Will raise PR when build is stable.
@authorjapps reminder! the PR has been pending for a while. Please can you help to merge it.