I am trying to pull a count of products from WooCommerece using the REST API:
http://www.skyverge.com/woocommerce-rest-api-docs.html#authentication/over-https
I can visit this page and I receive valid JSON:
https://[OMITTED].com/wc-api/v1
When I visit /wc-api/v1/products/count, I get a 404 error:
{"errors":[{"code":"woocommerce_api_authentication_error","message":"Consumer Key is missing"}]}
Under WooCommerce > Settings > Checkout, secure checkout has been enabled. Is my code incorrect? It works fine with a new 2.1 install.
Here is my code:
public bool Authenticate()
{
try
{
HttpWebRequest myHttpWebRequest = (HttpWebRequest)WebRequest.Create(m_BaseUrl + "/products/count");
//myHttpWebRequest.Accept = "text/xml";
string userP = m_UserName + ":" + m_Password;
byte[] authBytes = Encoding.UTF8.GetBytes(userP).ToArray();
myHttpWebRequest.Headers.Add("Authorization", "Basic " + Convert.ToBase64String(authBytes));
WebResponse httpResponse = myHttpWebRequest.GetResponse();
Stream responseStream = httpResponse.GetResponseStream();
StreamReader reader = new StreamReader(responseStream);
string resultData = reader.ReadToEnd();
responseStream.Close();
httpResponse.Close();
return true;
}
catch (Exception)
{
return false;
}
}
GET https://www.[OMITTED].com/wc-api/v1/products/count HTTP/1.1
Authorization: Basic [OMITTED]
Host [OMITTED]
Connection: Keep-Alive