# Customer-Resource create geht nicht

**URL:** https://forum.shopware.com/t/customer-resource-create-geht-nicht/44066
**Category:** Programmierung
**Created:** [27. Februar 2017 um 09:59 UTC](https://forum.shopware.com/t/customer-resource-create-geht-nicht/44066 "2017-02-27T09:59:46Z")
**Posts on this page:** 4
**Page:** 1

<div class="post-metadata">

### Author: ![hbee](https://avatars.discourse-cdn.com/v4/letter/h/f08c70/32.png) [@hbee](https://forum.shopware.com/u/hbee)
#### Post date: [27. Februar 2017 um 09:59 UTC](https://forum.shopware.com/t/customer-resource-create-geht-nicht/44066/1 "2017-02-27T09:59:46Z")

</div>

hi, ich versuche einen Customer wie folgt anzulegen.&nbsp;

```
$user_params = array(
                'email' => $__order['User']['email'],
                'groupKey' => 'AMZ',
                'shopId' => $__order['User']['shopID'],
                'paymentId' => 8,
                'billing' => array(
                    "salutation" => $__order['OrderBillingAddress']['salutation'],
                    "firstName" => $__order['OrderBillingAddress']['firstname'],
                    "lastName" => $__order['OrderBillingAddress']['lastname'],
                    "company" => $__order['OrderBillingAddress']['company'],
                    "street" => $__order['OrderBillingAddress']['street'],
                    "zipCode" => $__order['OrderBillingAddress']['zipcode'],
                    "city" => $__order['OrderBillingAddress']['city'],
                    "country" => $__order['OrderBillingAddress']['countryID'],
                ),
                'shipping' => array(
                    "salutation" => $__order['OrderBillingAddress']['salutation'],
                    "firstName" => $__order['OrderBillingAddress']['firstname'],
                    "lastName" => $__order['OrderBillingAddress']['lastname'],
                    "company" => $__order['OrderBillingAddress']['company'],
                    "street" => $__order['OrderBillingAddress']['street'],
                    "zipCode" => $__order['OrderBillingAddress']['zipcode'],
                    "city" => $__order['OrderBillingAddress']['city'],
                    "country" => $__order['OrderBillingAddress']['countryID'],
                ));

                try {
                if (empty($__order['User']['userID'])) {
                    $customer = $this->getShopwareCustomerResource()->create($user_params);
                   
                } else {
                    $customer = $this->getShopwareCustomerResource()->update(
                        $__order['User']['userID'],
                        $user_params
                    );

                }
            }catch(\Exception $e){
                Shopware()->Pluginlogger()->info('ERROR ON USER IMPORT/UPDATE', array($user_params,$e));
            }

```

Der User wird leider nicht angelegt. folgendes wird geloggt:

```
(Shopware\\Components\\Api\\Exception\\ValidationException(code: 0): at /www/htdocs/shopware/engine/Shopware/Bundle/AccountBundle/Service/Validator/CustomerValidator.php:99)"]

```

Also im Grunde wird kein Fehler ausgegeben aber es wird auch nichts angelegt. Alle Felder die Übergeben werden, sind gefüllt. Hat jemand eine Idee was hier nicht stimmt oder wie ich genauer debugen kann was hier nicht durch den Validator geht?

&nbsp;

---

<div class="post-metadata">

### Author: ![WillemMeert](https://avatars.discourse-cdn.com/v4/letter/w/5daacb/32.png) [@WillemMeert](https://forum.shopware.com/u/WillemMeert)
#### Post date: [5. März 2017 um 15:55 UTC](https://forum.shopware.com/t/customer-resource-create-geht-nicht/44066/2 "2017-03-05T15:55:32Z")

</div>

Validator kontrolliert ob ‚firstname‘ und ‚lastname‘ nicht Blank sind.

Dann wird ‚salutation‘ kontrolliert, im Standard Shop sollte das entweder ‚mr‘ oder ‚ms‘ sein. Waherscheinlich liegt hier den Fehler.

Schliesslich kontrolliert es die e-mail Adresse.

&nbsp;

---

<div class="post-metadata">

### Author: ![hbee](https://avatars.discourse-cdn.com/v4/letter/h/f08c70/32.png) [@hbee](https://forum.shopware.com/u/hbee)
#### Post date: [6. März 2017 um 11:35 UTC](https://forum.shopware.com/t/customer-resource-create-geht-nicht/44066/3 "2017-03-06T11:35:49Z")

</div>

> [@WillemMeert schrieb:](https://forum.shopware.com/profile/25932/WillemMeert "WillemMeert")
> 
> Validator kontrolliert ob ‚firstname‘ und ‚lastname‘ nicht Blank sind.
> 
> Dann wird ‚salutation‘ kontrolliert, im Standard Shop sollte das entweder ‚mr‘ oder ‚ms‘ sein. Waherscheinlich liegt hier den Fehler.
> 
> Schliesslich kontrolliert es die e-mail Adresse.
> 
> &nbsp;

vielen Dnak für deine Antwort. Leider hilft das nicht weiter. Die Felder sind wie geschrieben, alle gefüllt. salutation ist imme rmit ms gefüllt. &nbsp;

---

<div class="post-metadata">

### Author: ![WillemMeert](https://avatars.discourse-cdn.com/v4/letter/w/5daacb/32.png) [@WillemMeert](https://forum.shopware.com/u/WillemMeert)
#### Post date: [6. März 2017 um 13:58 UTC](https://forum.shopware.com/t/customer-resource-create-geht-nicht/44066/4 "2017-03-06T13:58:06Z")

</div>

‘firstname’, ‘lastname’ und ‘salutation’ müssen auch im array selbst angegeben werden, nicht nur in ‘billing’ und ‘shipping’ subobject !

Sehe Beispiel auf&nbsp;[REST API - Examples using the customer resource](https://developers.shopware.com/developers-guide/rest-api/examples/customer/) &nbsp;:

```
$client->post('customers', array(
    'email' => 'meier@mail.de',
    'firstname' => 'Max',
    'lastname' => 'Meier',
    'salutation' => 'mr',
    'billing' => array(
        'firstname' => 'Max',
        'lastname' => 'Meier',
        'salutation' => 'mr',
        'street' => 'Musterstrasse',
        'streetNumber' => '92',
        'city' => 'Sch\u00f6ppingen',
        'zipcode' => '48624',
        'country' => 2
    )
));

```

&nbsp;
