title: HTTPPost method with headers and body
body: <p>I need to make a HTTPPost reguest on Cloudsight for image recognition purpose. I have:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>BASE URL https://api.cloudsight.ai/v1/images</code></pre>
  </div>
  </div>
  </p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>Headers: Content-Type  application/json
          Authorization  Cloudsight API_KEY</code></pre>
  </div>
  </div>
  </p>
  
  <p>Its says: Send an image by using an HTTP POST request on the endpoint /images with either a multipart-form-encoded, or base64 encoded data parameter.
  url: <a href="http://docs.cloudsight.apiary.io/#reference/0/images-collection/send-an-image-for-identification?console=1" rel="nofollow noreferrer">http://docs.cloudsight.apiary.io/#reference/0/images-collection/send-an-image-for-identification?console=1</a>
  So far i have made this:</p>
  
  <p><div class="snippet" data-lang="js" data-hide="false" data-console="true" data-babel="false">
  <div class="snippet-code">
  <pre class="snippet-code-html lang-html prettyprint-override"><code>private class HTTPPOSTReguest extends AsyncTask&lt;String, Void, String&gt; {
          ProgressDialog dialog;
          String result = "";
          @Override
  
          protected void onPreExecute() {
  
          }
  
          @Override
          protected String doInBackground(String... params) {
  
              try {
  
                  HttpResponse response = null;
                  HttpClient httpclient = new DefaultHttpClient();
                  HttpPost httppost = new HttpPost(BASE_URL);
                  httppost.addHeader("Content-Type", "application/json");
                  httppost.addHeader("Authorization", "CloudSight buEA_pC6K7FXT60inM2eUQ");
  
                  ArrayList&lt;NameValuePair&gt; nameValuePairs = new ArrayList&lt;NameValuePair&gt;();
                  nameValuePairs.add(new BasicNameValuePair("images", encodedImage));
                 httppost.setEntity(new UrlEncodedFormEntity(nameValuePairs));
  
                  response = httpclient.execute(httppost);
                  int responseCode = response.getStatusLine().getStatusCode();
  
                  
                  HttpEntity entity = response.getEntity();
                  if (entity != null) {
                      String responseBody = EntityUtils.toString(entity);
                      result = responseBody;
                  }
              }  catch (IOException e) {
                  e.printStackTrace();
              }
              return result;
          }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Buth  can seem to make a successful reguest. Can someone offer advice</p>