2016-11-21 69 views
6

Magento ver'i kullanıyorum. 2.1.2 istirahat Api bu takip kullanıcı oluşturmak için:Php Magento Api Rest Müşteri Şifre Oluştur Yayınlama:

Next Exception: Report ID: webapi-583357a3bf02f; Message: Property "Password" does not have corresponding setter in class "Magento\Customer\Api\Data\CustomerInterface". in /var/www/html/www.magento.dev/vendor/magento/framework/Webapi/ErrorProcessor.php:195 

I: http://devdocs.magento.com/guides/m1x/api/rest/Resources/resource_customers.html#RESTAPI-Resource-Customers-HTTPMethod-POST-customers

$data = [ 
     "customer" => [ 
      "firstname" => 'Earl', 
      "lastname" => 'Hickey', 
      "email" => '[email protected]', 
      "password" => 'password', 
      "website_id" => 1, 
      'store_id' => 1, 
      "group_id" => 1 
     ] 
    ]; 

    $token = $this->get('lp_api')->getToken(); 
    $ch = curl_init($this->endpoint . 'customers'); 

    curl_setopt($ch, CURLOPT_CUSTOMREQUEST, "POST"); 
    curl_setopt($ch, CURLOPT_RETURNTRANSFER, true); 
    curl_setopt($ch, CURLOPT_POSTFIELDS, json_encode($data)); 
    curl_setopt($ch, CURLOPT_VERBOSE, true);  
    curl_setopt($ch, CURLOPT_HTTPHEADER, array(
     "Content-Type: application/json", "Authorization: Bearer " . json_decode($token), 
     ) 
    ); 

     // var_dump(curl_getinfo($c)); 
    $result = curl_exec($ch); 

i (yukarıdaki örnekte olduğu gibi) bir şifre gönderirseniz, ben şu hata var $ data dizisindeki "password" => 'password' ı kaldırırsam, bir kullanıcı şifre olmadan oluşturulur (bana göre garip geliyor).

Bu hatayla ilgili herhangi bir yardım bulamıyorum. Herhangi bir fikri olan var mı?

+0

Kontrol burada adım: http://magento.stackexchange.com/questions/150581/magento-2-how-to-call-rest- api-to-register-a-yeni-müşteri/156818 # 156818 – Manish

cevap

2

Magento 2.x sürümü için aşağıdaki bağlantıya bakın. http://devdocs.magento.com/swagger/index_20.html#/

Rest Api aracılığıyla müşteriler oluşturmak için aşağıdaki bedenleri kullandım ve düzgün çalışıyordu.

{ "müşteri": {

"e-posta": "[email protected].com", "ad": "x" "soyad": "y", "website_id": 1, "group_id": 1, "custom_attributes": [ { "attribute_code": "mobile_no", "değeri": "1234567890" } ]

}

"Parola": Adım kılavuz "123456"

}

+0

Teşekkürler, bir çekicilik gibi çalışır. Ama nasıl oldu, bu o dokümanda, şifre müşterinin bir parçası mı? http://devdocs.magento.com/guides/m1x/api/rest/Resources/resource_customers.html#RESTAPI-Resource-Customers-HTTPMethod-POST-müşterileri. Son olarak, bu bilgiyi nereden buldunuz? Bulabildiğim tek şey "customerAccountManagementV1" dir ve burada paroladan bahsedilmiyor. – user2227498

+0

Bağlantı: http://devdocs.magento.com/guides/m1x/api/rest/Resources/resource_customers.html#RESTAPI-Resource-Customers-HTTPMethod-POST-müşteriler – qwerty

+0

Yukarıdaki yorum için özür dilerim. Bağlantı: http://devdocs.magento.com/guides/m1x/api/rest/Resources/resource_customers.html#RESTAPI-Resource-Customers-HTTPMethod-POST-müşterileri , Magento 1.x sürümü için kullanılır. Dokümanda, sadece örnek vermişler ve kullandıklarımı paylaşmıştım. Yağmacıda, müşteriyle ilgili API'yi örnek olarak alacağınız customerCustomerRepositoryV1 bağlantısını tıklayabilirsiniz. – qwerty