title: JSON / Java / Twilio response: "No 'To' number is specified" when request sent from JSON
body: <p>Whatever I try, twilio is not accepting my JSON request for making a call. I keep getting "No 'To' number is specified". I am sending this from Java. And we intentionally didn't want to use Twilio Rest library.</p>
  
  <p><strong>JSON Response:</strong>
  {"code":21201, "message":"No 'To' number is specified", "more_info":"<a href="https://www.twilio.com/docs/errors/21201" rel="nofollow">https://www.twilio.com/docs/errors/21201</a>", "status":400}</p>
  
  <p><strong>JSON Request object</strong>
  {"Url":"http://twimlets.com/echo?Twiml=%3CResponse%3E%3CSay+voice%3D%22alice%22+language%3D%22en-IN%22%3EImportant+alert%3APlease+check+your+SMS%3C%2FSay%3E%3C%2FResponse%3E","To":"%2B919900299477","From":"%2B919900299477","Method":"POST","FallbackMethod":"POST","StatusCallbackMethod":"POST","Record":"false"}</p>
  
  <p><strong>Here's the source code:</strong></p>
  
  <pre><code>JSONObject jsonObject = new JSONObject();
  jsonObject.put("Url", "http://twimlets.com/echo?Twiml=" + URLEncoder.encode(
                      "&lt;Response&gt;&lt;Say voice=\"alice\" language=\"en-IN\"&gt;"
                      + psMessage + "&lt;/Say&gt;&lt;/Response&gt;", "UTF-8"));
  jsonObject.put("To", URLEncoder.encode(psNumberToCall, "UTF-8"));
  jsonObject.put("From", URLEncoder.encode("+919988776655", "UTF-8"));
  jsonObject.put("Method", "POST");
  jsonObject.put("FallbackMethod", "POST");
  jsonObject.put("StatusCallbackMethod", "POST");
  jsonObject.put("Record", "false");
  
  Log.i(getClass().getName(), "JSON Object: " + jsonObject.toString());
  
  HttpClient httpClient = new DefaultHttpClient();
  String sUrl = "https://api.twilio.com/2010-04-01/Accounts/AC****/Calls.json";
  HttpPost httpPost = new HttpPost(sUrl);
  StringEntity se = new StringEntity(jsonObject.toString());
  httpPost.setEntity(se);
  httpPost.setHeader("Accept", "application/json");
  httpPost.setHeader("content-type", "application/json");
  String authString = "Basic " + Base64.encodeToString 
        ((ACCOUNT_SID + ":" + AUTH_TOKEN).getBytes(), Base64.NO_WRAP);
  httpPost.setHeader("Authorization", authString);
  
  Log.i(getClass().getName(), "HttpPost: " + httpPost.toString());
  
  HttpResponse httpResponse = httpClient.execute(httpPost);
  InputStream is = httpResponse.getEntity().getContent();
  BufferedReader br = new BufferedReader(new InputStreamReader(is));
  StringBuilder sbResp = new StringBuilder();
  String sLine = "";
  while((sLine = br.readLine()) != null){
      sbResp.append(sLine);
  }
  is.close();
  return sbResp;
  </code></pre>