title: How to use Magento REST API from C#
body: <p>Where can I find samples that show how to connect to the Magento REST API using C#?</p>
  
  <p>I found was a php one which I could not figure out except a little.</p>
  
  <p>Using a Dropbox OAuth sample I found on the net I tried to make it work for Magento:</p>
  
  <pre><code>private void button1_Click(object sender, RoutedEventArgs e) 
  { 
      var consumerKey = “xxxxxxxxxxxxx”; 
      var consumerSecret = “xxxxxxxxxxxxxxxx”;
  
      var uri = new Uri("http://www.MagentoWebsite.com/oauth/token");
  
      // Generate a signature 
      OAuthBase oAuth = new OAuthBase(); 
      string nonce = oAuth.GenerateNonce(); 
      string timeStamp = oAuth.GenerateTimeStamp(); 
      string parameters; 
      string normalizedUrl; 
      string signature = oAuth.GenerateSignature(uri, consumerKey, consumerSecret, 
      String.Empty, String.Empty, “GET”, timeStamp, nonce, OAuthBase.SignatureTypes.HMACSHA1, 
      out normalizedUrl, out parameters);
  
      signature = HttpUtility.UrlEncode(signature);
  
      StringBuilder requestUri = new StringBuilder(uri.ToString()); 
      requestUri.AppendFormat("?oauth_consumer_key={0}&amp;", consumerKey); 
      requestUri.AppendFormat("oauth_nonce={0}&amp;", nonce); 
      requestUri.AppendFormat("oauth_timestamp={0}&amp;", timeStamp); 
      requestUri.AppendFormat("oauth_signature_method={0}&amp;", “HMAC-SHA1"); 
      requestUri.AppendFormat("oauth_version={0}&amp;", “1.0"); 
      requestUri.AppendFormat("oauth_signature={0}", signature);
  
      var request = (HttpWebRequest)WebRequest.Create(new Uri(requestUri.ToString())); 
      request.Method = WebRequestMethods.Http.Get;
  
      var response = request.GetResponse();
  
      var queryString = new StreamReader(response.GetResponseStream()).ReadToEnd();
  
      var parts = queryString.Split(’&amp;’); 
      var token = parts[1].Substring(parts[1].IndexOf(’=’) + 1); 
      var tokenSecret = parts[0].Substring(parts[0].IndexOf(’=’) + 1);
  
      queryString = String.Format("oauth_token={0}", token); 
      var authorizeUrl = “http://www.MagentoWebsite.com/admin/oauth_authorize?”+queryString; 
      Process.Start(authorizeUrl); 
  }
  </code></pre>
  
  <p>Unfortunately this returns a <code>BAD REQUEST</code> response. </p>