title: Google Search: How to construct a reverse image search URL (take 2)
body: <p>I have a need to use the Google reverse image search pragmatically, the thing is that they deprecated the version of the API
  that allowed to search images with images. In my scenario i can't really use the search image by text.</p>
  
  <p>So i decided to do a "quick" prototype by progragmatically posting the image to <a href="http://images.google.com/searchbyimage/upload" rel="nofollow noreferrer">http://images.google.com/searchbyimage/upload</a> 
  first i did it manually and sniffed with fiddler to see what was being posted, <a href="https://stackoverflow.com/a/7586422/1263288">I have also found this useful stackoverflow post.</a> ( mikerobi's take on it)</p>
  
  <p>Long story short the reason i need to post this to <a href="http://images.google.com/searchbyimage/upload" rel="nofollow noreferrer">http://images.google.com/searchbyimage/upload</a> is because i need to retrieve the tbs:sbi=xxx
  returned by the post; this "image fingerprint/encoded image" (which is not a base64 encoded image) is a parameter for a later post
  that will need to be done to retrieve the image results (again programatically)</p>
  
  <p>the parameters posted progragmatically are almost if not identical to the one done when using the browser 
  my sample code is the following; <strong>the result does give me a tbs:sbi=xxx but its not the correct one, what I'm I doing
  wrong?</strong></p>
  
  <p>here is a sample of my code</p>
  
  <pre><code>    [TestMethod]
      public void PostImageToGoogleAsBytes()
      {
          const string googleImageSearchUrl = @"http://images.google.com/searchbyimage/upload. ";
          const string imageToUpload = @"C:\Development\ReverseImageSearch\Tests\TestFiles\Images\sampleImage.jpg";
          HttpContent bytesContent = new ByteArrayContent(File.ReadAllBytes(imageToUpload));
          bytesContent.Headers.Add("Content-Type","image/jpeg");
          bytesContent.Headers.Add("filename", "sampleImage.jpg");
  
          using (var client = new HttpClient())
          {
              using (var formData = new MultipartFormDataContent())
              {
                  formData.Add(new StringContent(String.Empty),"image_url");
                  formData.Add(bytesContent, "encoded_image");
                  formData.Add(new StringContent(String.Empty), "fileName");
                  formData.Add(new StringContent(String.Empty), "image_content");
                  var response = client.PostAsync(googleImageSearchUrl, formData).Result;
                  Assert.IsTrue(response.IsSuccessStatusCode);
              }
          }
      }
  </code></pre>