title: Cognitive Service Computer vision API returning ' cache control error'
body: <p>I'm trying to use Microsoft Cognitive Service computer vision API in JavaScript. I have to upload a canvas image to the API and get the result.
  I used the same program with 'param' and 'URL' change with Face API and it is working just fine. but in Computer Vision API it is giving this error: 
  <strong>"Cache-Control: no-cache\r\nPragma: no-cache\r\nContent-Type: application/json; charset=utf-8\r\nExpires: -1\r\n"</strong></p>
  
  <p>My code is :</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-js lang-js prettyprint-override"><code>var apiKey = "&lt;KEY&gt;";
  var apiUrl = "https://westus.api.cognitive.microsoft.com/face/v1.0/detect";
  var params = {
              // Request parameters
              "maxCandidates": "1",
          };
          
  $('#btn').click(function () {
    var file = document.getElementById('filename').files[0];
    CallAPI(file, apiUrl, apiKey);
      
  
  
   });
   
  navigator.getUserMedia = ( navigator.getUserMedia ||
                           navigator.webkitGetUserMedia ||
                              navigator.mozGetUserMedia ||
                              navigator.msGetUserMedia);
  
  var video;
  var webcamStream;
  function startWebcam() {
      if (navigator.getUserMedia) {
    navigator.getUserMedia (
              {
                  video: true,
                  audio: false
              },
  
           function(localMediaStream) {
                   video = document.querySelector('video');
                   video.src = window.URL.createObjectURL(localMediaStream);
                    webcamStream = localMediaStream;
                 },
  
              function(err) {
                    console.log("The following error occured: " + err);
                 }
          );
      } 
      else {
       console.log("getUserMedia not supported");
      }  
  }
  
  function stopWebcam() {
            webcamStream.stop();
         }
  
  makeblob = function (dataURL) {
      var BASE64_MARKER = ';base64,';
      if (dataURL.indexOf(BASE64_MARKER) == -1) {
          var parts = dataURL.split(',');
          var contentType = parts[0].split(':')[1];
          var raw = decodeURIComponent(parts[1]);
          return new Blob([raw], { type: contentType });
      }
      var parts = dataURL.split(BASE64_MARKER);
      var contentType = parts[0].split(':')[1];
      var raw = window.atob(parts[1]);
      var rawLength = raw.length;
  
      var uInt8Array = new Uint8Array(rawLength);
  
      for (var i = 0; i &lt; rawLength; ++i) {
          uInt8Array[i] = raw.charCodeAt(i);
      }
  
      return new Blob([uInt8Array], { type: contentType });
  }
  
  
  function snapshot() {
   canvas = document.getElementById("myCanvas");
   ctx = canvas.getContext('2d');
   ctx.drawImage(video, 0,0, canvas.width, canvas.height);
   var dataurl= canvas.toDataURL();
   CallAPI(dataurl, apiUrl, apiKey);
  }
  setInterval(snapshot,10000);
  
  
  function CallAPI(file, apiUrl, apiKey)
  { console.log("api called");
    $.ajax({
              url: "https://westus.api.cognitive.microsoft.com/vision/v1.0/analyze?" + $.param(params),
              beforeSend: function(xhrObj){
                  // Request headers
                  xhrObj.setRequestHeader("Content-Type","application/json");
                  xhrObj.setRequestHeader("Ocp-Apim-Subscription-Key",apiKey);
              },
     type: "POST",
     data: makeblob(file),
     processData: false
    })
  
   .done(function (response) {
     ProcessResult(response);
     console.log("done");
   })
  
   .fail(function (error) {
     $("#response").text(error.getAllResponseHeaders());
              var str= JSON.stringify(error.getAllResponseHeaders())
     console.log(str);
   });
  }
   
  function ProcessResult(response)
  {
   // var data = JSON.parse(response);
      var string= JSON.stringify(response);
      var string = string.substring(1, string.length-1);
      var data= JSON.parse(string);
      console.log(string)   
  
  }</code></pre>
  </div>
  </div>
  </p>
  
  <p>Kindly help and suggest better way to do this. </p>