Woocommerce API ionic 3 POST error 401


Hi, i use woocommerce api on ionic app
(using nodejs module https://www.npmjs.com/package/woocommerce-api )

and all GET works but POST dosen’t !!

i’ve tried :

wc.postAsync('products', data).then((data) =>  {
}, (err) => { console.log('Error : ', err);  });

and i get 401 error

may any one help me to fix that ?
thanks :slight_smile:

WooCommerce API NPM implementation

How are you testing? OS?
What is your ionic info output?
Do the GET requests also use authentication?


in my website > wp-admin > woocommerce API > genearate KEY READ / Write
and then :

wc : any = WC({
  url: 'http://xxxxx.com',
  consumerKey: 'ck_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
  consumerSecret: 'cs_xxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxxx',
wc.getAsync('products/categories").then((data) =>  {
}, (err) => { console.log('err', err); });

but POST NOT WORKING with 401 error
i tried with chrom simulation (android & ios)
and i built apk and installed on my Android phone

Note that on chrome I add plugin allow controll allow origin to make gets works.

ionic info

cli packages: (/usr/lib/node_modules)

@ionic/cli-utils  : 1.13.1
ionic (Ionic CLI) : 3.13.2

global packages:

cordova (Cordova CLI) : 7.0.1 

local packages:

@ionic/app-scripts : 3.0.0
Cordova Platforms  : android 6.2.3
Ionic Framework    : ionic-angular 3.7.1


Android SDK Tools : 26.1.1
Node              : v6.11.2
npm               : 3.10.10 
OS                : Linux 4.9


backend : legacy


@Haroun did you solve this problem, I am getting the same error though the post is working from postman


@Vidit i use a php library, and from my client side i make simple post to:
in this file i make all my calls and authantication.

you can see the example here:


Did you find solution ? for post data


try with this one
wc : any = WC({

    wpAPI : true,
    queryStringAuth: true // Force Basic Authentication as query string true and using under HTTPS



Thank you kind sir, this worked like a charm…but tell why did it work…
what did these three lines of code change

    wpAPI : true,
    queryStringAuth: true


i have used this solution but it did not work for me. here is my screenshot. plz help me to solve this problem.1