title: Get JSON using OAuth 1.0 in vb.net
body: <p>I have a sample code in php. This sample shows how to get some data in JSON format from a vendors site.</p>
  
  <p>I am trying to write code in vb.net . I found some information <a href="https://www.codeproject.com/Articles/247336/Twitter-OAuth-authentication-using-Net" rel="nofollow noreferrer">https://www.codeproject.com/Articles/247336/Twitter-OAuth-authentication-using-Net</a>
  and I wrote something in vb but when I try to run the app, I am getting a 502 error in browser.</p>
  
  <p>The sample code is :</p>
  
  <pre><code>    &lt;?php
  
  $base_url = 'http://www.inart.com/';
  $gr_url   = $base_url . 'api/rest/products/store/1';   //Products in Greek language
  $en_url   = $base_url . 'api/rest/products/store/2';   //Products in English Language
  
  $consumer_key    = 'CONSUMER_KEY';
  $consumer_secret = 'CONSUMER_SECRET';
  $token           = 'TOKEN';
  $token_secret    = 'TOKEN_SECRET';
  
  $parameters = array();
  
  $headers    = array(
      'Content-Type' =&gt; 'application/json',
      'Accept'       =&gt; 'application/json'
  );
  
  $filters    = array(
      //Number of products per page (Default 10, Max 100)
      'limit' =&gt; 20,
      //Number of page to fetch
      'page'  =&gt; 1
  ); 
  //For more filters visit: http://devdocs.magento.com/guides/m1x/api/rest/get_filters.html
  
  $url = $gr_url . '?' . http_build_query($filters);
  
  try {
      $oauthClient = new OAuth($consumer_key, $consumer_secret, OAUTH_SIG_METHOD_HMACSHA1, OAUTH_AUTH_TYPE_AUTHORIZATION);
  
      $oauthClient-&gt;setToken($token, $token_secret);
  
      $oauthClient-&gt;fetch($url, $parameters, OAUTH_HTTP_METHOD_GET, $headers);
  
      $json = $oauthClient-&gt;getLastResponse();
  
      echo $json;
  } catch (Exception $e) {
      echo $e-&gt;getMessage();
  }
  </code></pre>
  
  <p>The vb code is :</p>
  
  <pre><code> Protected Sub Button1_Click(sender As Object, e As EventArgs) Handles Button1.Click
      Dim consumer_key = "3626311748bcf2072da2bd475fccfa3c"
      Dim consumer_secret = "0cbb0df8d840e22b96d4f80449e7e0b7"
      Dim token = "82c43c4cbff206316428860ee25da63d"
      Dim token_secret = "986d1996d22ccffa51dc960c041d4b74"
      Dim oauth_version = "1.0"
      Dim oauth_signature_method = "HMAC-SHA1"
      Dim base_url = "http://dev.inart.gr/api/rest/products/store/1"
  
      Dim baseFormat = "oauth_consumer_key={0}&amp;oauth_signature_method={1}" + "&amp;oauth_token={2}&amp;oauth_version={3}"
  
      Dim baseString = String.Format(baseFormat, consumer_key, oauth_signature_method, token, oauth_version)
  
      baseString = String.Concat("POST&amp;", Uri.EscapeDataString(base_url), "&amp;", Uri.EscapeDataString(baseString))
  
      Dim compositeKey = String.Concat(Uri.EscapeDataString(consumer_secret), "&amp;", Uri.EscapeDataString(token_secret))
  
      Dim oauth_signature As String
      Using hasher As New HMACSHA1(ASCIIEncoding.ASCII.GetBytes(compositeKey))
          oauth_signature = Convert.ToBase64String(hasher.ComputeHash(ASCIIEncoding.ASCII.GetBytes(baseString)))
      End Using
  
      Dim headerFormat = "OAuth oauth_signature_method=""{0}"", " + "oauth_consumer_key=""{1}"", " + "oauth_token=""{2}"", oauth_signature=""{3}"", " + "oauth_version=""{4}"""
  
      Dim authHeader = String.Format(headerFormat, Uri.EscapeDataString(oauth_signature_method), Uri.EscapeDataString(consumer_key), Uri.EscapeDataString(token),
      Uri.EscapeDataString(oauth_signature), Uri.EscapeDataString(oauth_version))
  
      Dim request As HttpWebRequest = DirectCast(WebRequest.Create(base_url), HttpWebRequest)
      request.Headers.Add("Authorization", authHeader)
      request.Method = "POST"
      request.ContentType = "application/json"
      request.Accept = "application/json"
      Dim response As WebResponse = request.GetResponse()
      MsgBox(response.ToString)
  End Sub
  </code></pre>
  
  <p>The error is in line 39:Dim response As WebResponse = request.GetResponse()
  as browser says. 
  Thanks for any help.
  Sorry for my bad english.</p>