java - How do I add UrlEncodedFormEntity to a MultipartEntityBuilder -


i have file want upload have standard multipartentitybuilder this:

multipartentitybuilder multipartentity = multipartentitybuilder.create(); multipartentity.addbinarybody("file", file); 

i have form params send post this:

arraylist<namevaluepair> postparameters = new arraylist<namevaluepair>(); postparameters.add(new basicnamevaluepair("userid",userid)); postparameters.add(new basicnamevaluepair("taskid",taskid)); new urlencodedformentity(postparameters) 

both work individually, question how do both in 1 call? need fold 1 other can make in 1 httppost() call.

you seem confusing application/x-www-form-urlencoded , multipart/form-data content types. when sending multipart request, using multipart/form-data, in case don't need url encode content. set text directly

multipartentitybuilder multipartentitybuilder = multipartentitybuilder.create(); multipartentitybuilder.addbinarybody("file", file); multipartentitybuilder.addtextbody("userid", "someidwith@url$encodable<>characters"); 

see specification more details.


Comments

Popular posts from this blog

user interface - How to replace the Python logo in a Tkinter-based Python GUI app? -

objective c - Greedy NSProgressIndicator Allocation -

how to set an OCR language in Google Drive -