2

I am trying to send file/image over the network using volley request with the help of multipart request.

But I am getting following error:

    java.lang.NoClassDefFoundError: Failed resolution of: Lorg/apache/http/entity/ContentType; at org.apache.http.entity.mime.content.FileBody.<init>(FileBody.java:89)at com.employwise.ggs.network.MultipartRequest.buildMultipartEntity(MultipartRequest.java:41)at com.employwise.ggs.network.MultipartRequest.<init>(MultipartRequest.java:35)

Here I am calling volley request:

String url = "my url"
            String s = new JSONObject(new Gson().toJson(Infotype Class)).toString();
            HashMap <String,String> map = new HashMap<>();
            map.put("data",s);
            MultipartRequest multipartRequest = new MultipartRequest(url, new Response.ErrorListener() {
                @Override
                public void onErrorResponse(VolleyError volleyError) {
                    Toast.makeText(context,"Error in Upload",Toast.LENGTH_SHORT).show();
                }
            }, new Response.Listener<String>() {
                @Override
                public void onResponse(String s) {
                 Toast.makeText(context,"SuccessFully enter code here`Uploaded",Toast.LENGTH_SHORT).show();
                }
            },new File(picturePath),map);
            networkCall.addToRequestQueue(multipartRequest);

I don't know what I am doing wrong here and also don't know where to set content type in multipart request.

By debugging I got uncaught runtime exception and content type null in this line (entity.addPart(FILE_PART_NAME, new FileBody(mFilePart));).

Ritz
  • 181
  • 1
  • 1
  • 10
  • If your project uses API 23, read the following http://stackoverflow.com/questions/32240177/working-post-multipart-request-with-volley-and-without-httpentity – BNK Oct 12 '15 at 08:32

0 Answers0