title: how do I use WooCommerce from C# to post a record
body: <p>So I have a worpress site with woo commerce. I am in the process of writing a C# WebApi rest app to interact with the wordpress site. So far I can catch things like new product creation, order creation from woo using webhooks.</p>
  <p>Now I'm trying to go the other way and in this case post a new product into wordpress from my api.</p>
  <p>I have installed the latest version of WooCommerce.Net from Nuget (V4.0.30319).</p>
  <p>So for test purposes I've created a product :</p>
  <pre><code>var wooProduct = new WooCommerceNET.WooCommerce.v3.Product
              {
                  name = &quot;test product&quot;,
                  type = &quot;simple&quot;,
                  regular_price = 23.99m,
                  description = &quot;test product to see if I can create a product using rest APi&quot;,
                  short_description = &quot;this is a short desc&quot;,
                  shipping_required = true,
                  stock_quantity = 20
              };
              wooProduct.categories = new List&lt;ProductCategoryLine&gt;();
              wooProduct.categories.Add(new ProductCategoryLine { id = 1 });
  </code></pre>
  <p>Then to send it I have:</p>
  <pre><code> var fullEndPoint = string.Concat(site, &quot;/wp-json/wc/v3/&quot;, endpoint);
  
                  var serializedData = JsonConvert.SerializeObject(postdata);
  
                  HttpWebRequest request = (HttpWebRequest)WebRequest.Create(fullEndPoint);
                  request.Method = &quot;POST&quot;;
                  request.ContentType = &quot;application/json&quot;;
                  request.Headers.Add(&quot;consumer_key&quot;, woosecret);
                  string encoded = System.Convert.ToBase64String(Encoding.GetEncoding(&quot;ISO-8859-1&quot;)
                                             .GetBytes(username + &quot;:&quot; + password));
                  request.Headers.Add(&quot;Authorization&quot;, &quot;Basic &quot; + encoded);
                  using (StreamWriter swJSONPayload = new StreamWriter(request.GetRequestStream()))
                  {
                      swJSONPayload.Write(serializedData);
                      swJSONPayload.Close();
                  }
  </code></pre>
  <p>but nothing get's across and I dont receive any error's. The Documentation says that the</p>
  <blockquote>
  <p>WooCommerceNET.RestAPI</p>
  </blockquote>
  <p>is deprecated and all examples do not show how to send from C#. If anyone can point me in the right direction I'd be very grateful.</p>
  <p>Update: I added Basic Authorisation where the username and password are a valid user set up on wordpress/woo. I now receive a 401 unauthorized error, but dont know what else I need to give to allow this to go through.</p>
  <p>Update 2: I didn't have basic authentication enabled in IIS. Now that I've done that I receive an error suggesting that IIS could not verify the identity of the username and password provided. These details are configured in wordpress and isn't system wide. I'm running all of this on a windows 10 developer machine at the moment, so there is no Active Directory either.</p>