java


Android OkHttp3 and Spring.io Post Multipart Data


I try to post multipart data to my server, but it won't work. My Server is build with the spring.io framework and my client are an android device.
if I tried with an external rest client, all worked fine. But in my android device, there got an error.
Here is what the server server will do:
#RequestMapping(value = "/", method = RequestMethod.POST)
public EntryImage uploadImage(#RequestParam("file") MultipartFile file,
#RequestParam("entry_id") int entryId,
#RequestParam("sub_title") String subTitle,
#RequestParam("uploader") long uploader) {
// here is the logic...
}
and here is what I do in android. I Use okhttp3 to query http requests:
public static final MediaType MEDIA_TYPE_PNG = MediaType.parse("image/png");
File file = ImageHelper.getBitmapFile(NewEntryActivity.this, IMAGE.getImage());
FormBody formBody = new FormBody.Builder()
.add("entry_id", String.valueOf(entryContract.getEntry_id()))
.add("uploader", "1")
.add("sub_title", "-")
.build();
RequestBody requestBody = new MultipartBody.Builder()
.setType(MultipartBody.FORM)
.addFormDataPart("file", "file", RequestBody.create(mediaType, file))
.addPart(formParams)
.build();
Request request = new Request.Builder()
.url(url)
.post(requestBody)
.build();
client.newCall(request).enqueue(callback);
when I enqueue this request, I get an error-code 400 with the message "Required int parameter 'entry_id' is not present"
what do I wrong? How can I post form data from android to spring service?
I already tried to set the "RequestParam"-Types to String (cause in OkHttp I only can add strings to the formBody) but I get the same error.

Related Links

What is the fastest file / way to parse a large data file?
how to search for a java open source application? [closed]
Hibernate - Difference between bytecode instrumentation and bytecode enhancement?
OptimisticLockException while deleting a set of entities concurrently
Java - Is ObjectInput/OutputStream compatible with DataInput/OutputStream?
Mockito, JUnit and Map nested in another class
Jsoup trouble to select menuitem
java- use scanner to read in and process one piece of information at a time
How do I stop iteration in Java using Apache POI
Simplicity/testability dilemma [duplicate]
Creating two dimensional arrays from a given Object Vector
Match any unicode Letters with java regex
How does Common Language Infrastructure work and what is its purpose?
How to set date of birth in an android form without datepicker control
It is possible when inputStream.available != 0 the complete data has not been received?
How to Drag and Drop a text file in new tab using swing

Categories

HOME
compiler-construction
gitlab
minimum-spanning-tree
tinymce
relay
getelementsbytagname
graphql
fsm
blueprintjs
ezpublish
ios-charts
qore
slick-slider
dacpac
izpack
etl
timeout
vb.net-2010
connection-string
excel-vba-mac
google-cloud-speech
predix
autocad-plugin
paging
scriptcs
excel-2007
extjs5
icloud-api
javacv
qhull
pepper
semantic-analysis
poltergeist
uninstall
entitlements
fluentvalidation
kendo-datasource
c++-amp
nouislider
socialengine
uisplitview
repo
subset-sum
fusionpbx
bitbucket-pipelines
objectlistview
c11
document.write
webdriver-manager
leading-zero
optix
isbn
estimote
angular-resource
theming
promela
alphabet
typescript1.8
composite-key
lift-json
snmptrapd
mcafee
spring-cache
gnome-shell-extensions
parallel-data-warehouse
contact-list
react-native-listview
bluemix-app-scan
freedesktop.org
spim
r-tree
teamcity-8.0
endeca-workbench
wyam
sailfish-os
composite
pick
responsive-slides
mesa
has-many-through
dml
multiprocessor
quantlib-swig
gridfs
flash-builder4.5
jplaton
hamiltonian-cycle
libstdc++
dbproviderfactories
servicehost
w3wp.exe
gin
jquery-ui-droppable
nhibernate.search
perfect-hash
ubuntu-9.04

Resources

Mobile Apps Dev
Database Users
javascript
java
csharp
php
android
MS Developer
developer works
python
ios
c
html
jquery
RDBMS discuss
Cloud Virtualization
Database Dev&Adm
javascript
java
csharp
php
python
android
jquery
ruby
ios
html
Mobile App
Mobile App
Mobile App