小编use*_*498的帖子

Php Magento Api Rest创建客户密码问题:

我正在使用Magento ver.2.1.2 Rest Api创建用户,如下所示: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" => 'earl-2@example.com',
            "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);
Run Code Online (Sandbox Code Playgroud)

如果我发送密码(如上例所示),我有以下错误:

Next Exception: Report …
Run Code Online (Sandbox Code Playgroud)

php api rest magento magento2

6
推荐指数
1
解决办法
1121
查看次数

标签 统计

api ×1

magento ×1

magento2 ×1

php ×1

rest ×1