Hello I am using WooCommerce API - Node.js Client https://www.npmjs.com/package/woocommerce-api
And I am trying to create a customer which requires a POST request to the server. Here is the code to initialize woocomerece REST API:
var WooCommerceAPI = require('woocommerce-api');
var WooCommerce = new WooCommerceAPI({
url: 'http://example.com',
consumerKey: 'ck_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
consumerSecret: 'cs_XXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXXX',
wpAPI: true,
version: 'wc/v1'
});
This is the code to Create customer:
var data = {
email: 'john.doe@example.com',
first_name: 'John',
last_name: 'Doe',
username: 'john.doe',
billing: {
first_name: 'John',
last_name: 'Doe',
company: '',
address_1: '969 Market',
address_2: '',
city: 'San Francisco',
state: 'CA',
postcode: '94103',
country: 'US',
email: 'john.doe@example.com',
phone: '(555) 555-5555'
},
shipping: {
first_name: 'John',
last_name: 'Doe',
company: '',
address_1: '969 Market',
address_2: '',
city: 'San Francisco',
state: 'CA',
postcode: '94103',
country: 'US'
}
};
WooCommerce.post('customers', data, function(err, data, res) {
console.log(res);
});
But I keep getting the following response from server.
{
"code":"woocommerce_rest_authentication_error",
"message":"Invalid signature - provided signature does not match.",
"data":{"status":401}
}
However any GET request to the works on the server eg: I can get the list of products.