0

I am sending image and text to server using Multi part. I am getting error as I need to send empty string in one parameter like:

HashMap<String, String> Map = new HashMap<String, String>();
Map.put("course_id",  "");

In Asynctask,

MultipartEntity reqEntity = null;
StringBody course_id = null;
course_id = new StringBody(map.get("course_id"));
reqEntity = new MultipartEntity(HttpMultipartMode.BROWSER_COMPATIBLE);
reqEntity.addPart("course_id", course_id );

Here it is throwing exception and response is in HTML. My requirement is to send empty string and whenever I send empty string it throws exception so how would I send empty string?

ERROR :

 <!doctype html>
                                                          <html lang='en'>
                                                          <head>
                                                              <meta charset='UTF-8'>
                                                              <meta http-equiv="X-UA-Compatible" content="IE=edge"/>
                                                              <title>Wrong turn!</title>
                                                              <link href='http://fonts.googleapis.com/css?family=Lato:300,400' rel='stylesheet' type='text/css'>
                                                              <link rel="shortcut icon" href="http://images.qourier.com/imgs/images/favicon.ico">
                                                              <link rel="apple-itouch-icon" href="http://images.com/imgs/images/favicon.png">
                                                          </head>
                                                          <style>

   org.json.JSONException: Value <!doctype of type java.lang.String cannot     be converted to JSONObject
   at org.json.JSON.typeMismatch(JSON.java:111)

Thanks!

Bansi Doshi
  • 229
  • 1
  • 3
  • 12

0 Answers0