簡體   English   中英

Ionic 3 WP-REST API發布請求401(未經授權)錯誤

[英]Ionic 3 WP-REST API Post request 401 (unauthorized) error

我正在開發一個簡單的應用程序,以通過wp-rest api在Wordpress(woocommerce)中創建用戶。 但是當我嘗試創建新客戶時,它在控制台中顯示401 Unauthorized錯誤。 這是我的要求代碼。

 signup(){ let customerData = { customer : {} } customerData.customer = { "email": this.newUser.email, "first_name": this.newUser.first_name, ... "billing_address": { "first_name": this.newUser.first_name, ... }, "shipping_address": { "first_name": this.newUser.first_name, ... } } if(this.billing_shipping_same){ this.newUser.shipping_address = this.newUser.shipping_address; } this.WooCommerce.postAsync('customers', customerData).then( (data) => { console.log(JSON.parse(data.body)); }) } 

順便說一句,關鍵客戶和秘密是正確的 在此處輸入圖片說明

您需要一個https連接,將以下行添加到woocommerce init中:

verifySsl: false,
queryStringAuth: true

任何post請求都需要https連接。

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM