title: Error While sending Json data to server with Base64 encoded image string
body: <p><strong>in my code i am sending the json data like this</strong></p>
  
  <pre><code>ByteArrayOutputStream baos = new ByteArrayOutputStream();
                          imgbmp.compress(Bitmap.CompressFormat.PNG, 90, baos);
                          byte[] b = baos.toByteArray();
                          String encodedImage = Base64.encodeBytes(b);
                          jsonstr = new JSONStringer().object().key("Text")
                                  .value(msg).key("Files").array().object().key(
                                          "ContentType").value("image/png").key(
                                          "Content").value(encodedImage)
                                  .endObject().endArray().key("AuthToken").value(token)
                                  .endObject();
  
  StringEntity entity = new StringEntity(jsonstr.toString());
                      entity.setContentType("application/json;charset=UTF-8");
                      entity.setContentEncoding(new BasicHeader(HTTP.CONTENT_TYPE,"application/json;charset=UTF-8"));
                      request.setEntity(entity);
                      DefaultHttpClient httpClient = new DefaultHttpClient();
  
                      HttpResponse res = httpClient.execute(request);
  </code></pre>
  
  <p><strong>and i am getting this error while executing the HttpClient</strong></p>
  
  <pre><code>09-30 11:56:21.571: INFO/Request(22161): org.apache.http.client.methods.HttpPost@468613b0
  09-30 11:56:21.586: INFO/JSON ANS(22161): &lt;Fault xmlns="http://schemas.microsoft.com/ws/2005/05/envelope/none"&gt;&lt;Code&gt;&lt;Value&gt;Receiver&lt;/Value&gt;&lt;Subcode&gt;&lt;Value xmlns:a="http://schemas.microsoft.com/net/2005/12/windowscommunicationfoundation/dispatcher"&gt;a:InternalServiceFault&lt;/Value&gt;&lt;/Subcode&gt;&lt;/Code&gt;&lt;Reason&gt;&lt;Text xml:lang="en-US"&gt;The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters. &lt;/Text&gt;&lt;/Reason&gt;&lt;Detail&gt;&lt;ExceptionDetail xmlns="http://schemas.datacontract.org/2004/07/System.ServiceModel" xmlns:i="http://www.w3.org/2001/XMLSchema-instance"&gt;&lt;HelpLink i:nil="true"/&gt;&lt;InnerException i:nil="true"/&gt;&lt;Message&gt;The input is not a valid Base-64 string as it contains a non-base 64 character, more than two padding characters, or a non-white space character among the padding characters. &lt;/Message&gt;&lt;StackTrace&gt;   at System.Convert.FromBase64String(String s)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at Zoodig.Core.WebServices.DataContracts.FileContract.GetStream()&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at Zoodig.WebServices.Services.AthletesService.PostUpdate(PostUpdateContract data)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at SyncInvokePostUpdate(Object , Object[] , Object[] )&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.SyncMethodInvoker.Invoke(Object instance, Object[] inputs, Object[]&amp;amp; outputs)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.DispatchOperationRuntime.InvokeBegin(MessageRpc&amp;amp; rpc)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage5(MessageRpc&amp;amp; rpc)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage41(MessageRpc&amp;amp; rpc)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage4(MessageRpc&amp;amp; rpc)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage31(MessageRpc&amp;amp; rpc)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage3(MessageRpc&amp;amp; rpc)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage2(MessageRpc&amp;amp; rpc)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage11(MessageRpc&amp;amp; rpc)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.ImmutableDispatchRuntime.ProcessMessage1(MessageRpc&amp;amp; rpc)&amp;#xD;
  09-30 11:56:21.586: INFO/JSON ANS(22161):    at System.ServiceModel.Dispatcher.MessageRpc.Process(Boolean isOperationContextSet)&lt;/StackTrace&gt;&lt;Type&gt;System.FormatException&lt;/Type&gt;&lt;/ExceptionDetail&gt;&lt;/Detail&gt;&lt;/Fault&gt;
  </code></pre>
  
  <p><strong>Please if anyone can understand this and tell me whats happening here..where are the posibilities that i have made any mistakes..and why i am getting the error?</strong></p>
  
  <p>Thank You.
  MKJParekh</p>