title: Microsoft Cognitive Services: Uploading image
body: <p>I am trying to upload an image to the Microsoft Computer Vision API from a mobile device, but I am constantly receiving a 400 Bad Request for Invalid File Format "Input data is not a valid image". The documentation states that I can send the data as application/octet-stream in the following form:</p>
  
  <blockquote>
    <p>[Binary image data]</p>
  </blockquote>
  
  <p>I have the data of the image in terms of base64 encoding ("/9j/4AAQSkZJ.........."), and I also have the image as a FILE_URI, but I can't seem to figure out the format in which to send the data. Here is a sample code:</p>
  
  <pre><code>$(function() {
      $.ajax({
          url: "https://api.projectoxford.ai/vision/v1.0/describe",
          beforeSend: function (xhrObj) {
              // Request headers
              xhrObj.setRequestHeader("Content-Type", "application/octet-stream");
              xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key", computerVisionKey);
          },
          type: "POST",
          // Request body
          data: base64image,
          processData: false        
      })
      .done(function(data) {
        alert("success");
      })
      .fail(function(error) {
        alert("fail");
      });
  });
  </code></pre>
  
  <p>I've tried the following:</p>
  
  <ul>
  <li>[base64image]</li>
  <li>{base64image} </li>
  <li>"data:image/jpeg;base64," + base64image</li>
  <li>"image/jpeg;base64," + base64image</li>
  </ul>
  
  <p>and more.</p>
  
  <p>I did tested these on the Computer Vision API console. Is it because base64 encoded binary isn't an acceptable format? Or am I sending it in the incorrect format completely?</p>
  
  <p>Note: The operation works when sending a URL as application/json.</p>