Error occurred when we try to use postAsync function of woocommerce on IOS build of an IONIC APP


#1

We are using woocommerce and Wordpress APIs and functions in our IONIC app everything looks good but the only thing does’ nt work is the “ postAsync ” function to place an order.

The most interesting part is everything looks good on my Android build but the issue is only appeared on my IOS build.

Please help me in this regards.Below you will find all the details for the issue.

401 (Unauthorized)
Response for preflight has invalid HTTP status code 401.

polyfills.js:3 OPTIONS http://gmontierth.com/wc-api/v3/orders?oauth_consumer_key=ck_b4ab2fc9ce7a3ef35afcd0ae19efb9618dfbb43f&oauth_nonce=TullzbCIfeJNAyGZbDJmFvi8WtxCdOdC&oauth_signature_method=HMAC-SHA256&oauth_timestamp=1521738924&oauth_version=1.0&oauth_signature=frmtTPmGFMwfHdG6B4K7PCvc8%2BG%2FYHFQPHcQ2HrDuNc%3D 401 (Unauthorized)

Failed to load http://gmontierth.com/wc-api/v3/orders?oauth_consumer_key=ck_b4ab2fc9ce7a3ef35afcd0ae19efb9618dfbb43f&oauth_nonce=TullzbCIfeJNAyGZbDJmFvi8WtxCdOdC&oauth_signature_method=HMAC-SHA256&oauth_timestamp=1521738924&oauth_version=1.0&oauth_signature=frmtTPmGFMwfHdG6B4K7PCvc8%2BG%2FYHFQPHcQ2HrDuNc%3D: Response for preflight has invalid HTTP status code 401.

* Request URL: http://gmontierth.com/wc-api/v3/orders?oauth_consumer_key=ck_b4ab2fc9ce7a3ef35afcd0ae19efb9618dfbb43f&oauth_nonce=PTiM8ejkm6NtPqKbKHf9lSbsiQNwI8kC&oauth_signature_method=HMAC-SHA256&oauth_timestamp=1521738622&oauth_version=1.0&oauth_signature=m%2BirT7fvahoH64FC1iXNPY0tzWthxU%2BRw6M%2FJHHFec0%3D
* Request Method: OPTIONS
* Status Code: 401 Unauthorized
* Remote Address: 99.198.97.114:80
* Referrer Policy: no-referrer-when-downgrade

this.WooCommerce.postAsync(“orders”, orderData).then((data) => {


#2

You have to make sure this OPTIONS request doesn’t respond with code 401.

Did you remote debug the problem on the device already?
Follow these instructions here to debug the problem in Safari dev tools:
https://ionic.zone/debug/remote-debug-your-app#ios
Follow these instructions here to debug the problem in Chrome dev tools:
https://ionic.zone/debug/remote-debug-your-app#android
Look at the console and network tabs for errors.