# HTTP 500 nach API POST request auf Customer

**URL:** <https://forum.shopware.com/t/http-500-nach-api-post-request-auf-customer/95017>\
**Category:** Shopware 6 (German)\
**Tags:** administration, programming\
**Created:** [28. Juni 2022 um 18:04 UTC](https://forum.shopware.com/t/http-500-nach-api-post-request-auf-customer/95017 "2022-06-28T18:04:17Z")\
**Posts on this page:** 7\
**Page:** 1

<div class="post-metadata">

**Author:** ![ayti](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@ayti](https://forum.shopware.com/u/ayti)\
**Post date:** [28. Juni 2022 um 18:04 UTC](https://forum.shopware.com/t/http-500-nach-api-post-request-auf-customer/95017/1 "2022-06-28T18:04:17Z")

</div>

Hallo zusammen,

ich benötige Unterstützung um eine erfolgreiche API Post request auf:  
[https://xxxxxxxx.com/api/customer](https://xxxxxxxx.com/api/customer)

zu machen.

Der Body von der Request sieht wie folgt aus:

```auto
{
"customerNumber": "TestUser1",
"groupId": "PlatzhalterGroupId", 
"salesChannelId": "PlatzhalterSalesChannelId",
"email": "test2@xxxxxx.com",
"firstName":"TestVorname",
"lastName":"TestName",
"defaultPaymentMethodId": "PlatzhalterPaymentMethodId",
"defaultBillingAddress": [
    {
    "firstName": "TestVorname",
    "lastName":"TestName",
    "street": "Teststraße 11",
    "zipcode": "12345",
    "city": "Teststadt",
    "countryId": "PlatzhalterCountryID"
    }
],
"defaultShippingAddress": [
   {
    "firstName": "TestVorname",
    "lastName":"TestName",
    "street": "Teststraße 111",
    "zipcode": "12345",
    "city": "Teststadt",
    "countryId": "PlatzhalterCountryID"
    }
],
"guest": true
}

```

Bei der Request bekomme ich aktuell folgenden Fehler:

> „code“: „0“,  
> „status“: „500“,  
> „title“: „Internal Server Error“,  
> „detail“: „Shopware\Core\Framework\DataAbstractionLayer\Write\DataStack\KeyValuePair::\_\_construct(): Argument #1 ($key) must be of type string, int given, called in xxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/DataStack/DataStack.php on line 47“

Ich bin noch sehr neu was die shopware APIs angeht, vielleicht habe ich irgendetwas essentielles vergessen (Die Doku zu Admin API, hat mir nicht alle Fragen beantworten können).

Vielen Dank & Viele Grüße

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [28. Juni 2022 um 19:31 UTC](https://forum.shopware.com/t/http-500-nach-api-post-request-auf-customer/95017/2 "2022-06-28T19:31:59Z")

</div>

@ayti, hast du dir mal den Stacktrace angeguckt?  
Da wird irgendwo ein int als key verwendet. Leider ist es ohne weitere Informationen schwierig aus der Ferne zu helfen.

---

<div class="post-metadata">

**Author:** ![ayti](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@ayti](https://forum.shopware.com/u/ayti)\
**Post date:** [28. Juni 2022 um 19:45 UTC](https://forum.shopware.com/t/http-500-nach-api-post-request-auf-customer/95017/3 "2022-06-28T19:45:49Z")

</div>

@abdullah stehe gerade etwas auf dem schlauch. Wie kann ich das einsehen 🙂 ? Weil im Shopware Log und Server Log steht es nicht drin. In der response welche ich in Postman sehe steht nur das was ich schon geschrieben habe. In Postman sehe ich auch keine weiteren Infos. Danke!

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [28. Juni 2022 um 20:03 UTC](https://forum.shopware.com/t/http-500-nach-api-post-request-auf-customer/95017/4 "2022-06-28T20:03:58Z")

</div>

@ayti, die Fehlermeldung müsstest du im PHP Error Log finden. Ich kenne jetzt dein System um zu sagen wo die Log Datei liegt.  
Ggf. musst du den dev Modus aktivieren.

Wie sehen denn die Params und Headers des Requests aus?

---

<div class="post-metadata">

**Author:** ![ayti](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@ayti](https://forum.shopware.com/u/ayti)\
**Post date:** [29. Juni 2022 um 05:13 UTC](https://forum.shopware.com/t/http-500-nach-api-post-request-auf-customer/95017/5 "2022-06-29T05:13:25Z")

</div>

@abdullah, den Body der Request siehst du oben.  
Der Header sieht wie folgt aus:

```auto
Authorization: Bearer Platzhaltertoken
Accept: application/json
Content-Type: application/json
User-Agent: Testing1

```

Folgendes wird nun als Fehler angezeigt:

```auto
{
    "errors": [
        {
            "code": "0",
            "status": "500",
            "title": "Internal Server Error",
            "detail": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\DataStack\\KeyValuePair::__construct(): Argument #1 ($key) must be of type string, int given, called in /xxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/DataStack/DataStack.php on line 47",
            "meta": {
                "trace": [
                    {
                        "file": "/xxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/DataStack/DataStack.php",
                        "line": 47,
                        "function": "__construct",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\DataStack\\KeyValuePair",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/WriteCommandExtractor.php",
                        "line": 303,
                        "function": "__construct",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\DataStack\\DataStack",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/WriteCommandExtractor.php",
                        "line": 209,
                        "function": "map",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\WriteCommandExtractor",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/FieldSerializer/ManyToOneAssociationFieldSerializer.php",
                        "line": 115,
                        "function": "extract",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\WriteCommandExtractor",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/WriteCommandExtractor.php",
                        "line": 318,
                        "function": "encode",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\FieldSerializer\\ManyToOneAssociationFieldSerializer",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/WriteCommandExtractor.php",
                        "line": 209,
                        "function": "map",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\WriteCommandExtractor",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/EntityWriter.php",
                        "line": 195,
                        "function": "extract",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\WriteCommandExtractor",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/EntityWriter.php",
                        "line": 140,
                        "function": "write",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\EntityWriter",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/VersionManager.php",
                        "line": 118,
                        "function": "insert",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\EntityWriter",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxxxx/vendor/shopware/core/Framework/DataAbstractionLayer/EntityRepository.php",
                        "line": 154,
                        "function": "insert",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\VersionManager",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxxxx/vendor/shopware/core/Framework/Api/Controller/ApiController.php",
                        "line": 916,
                        "function": "create",
                        "class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxxxxxxx/vendor/shopware/core/Framework/Context.php",
                        "line": 207,
                        "function": "Shopware\\Core\\Framework\\Api\\Controller\\{closure}",
                        "class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
                        "type": "->"
                    },
                    {
                        "file": "/vxxxxxxxxxxx/vendor/shopware/core/Framework/Api/Controller/ApiController.php",
                        "line": 934,
                        "function": "scope",
                        "class": "Shopware\\Core\\Framework\\Context",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxx/vendor/shopware/core/Framework/Api/Controller/ApiController.php",
                        "line": 778,
                        "function": "executeWriteOperation",
                        "class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxx/vendor/shopware/core/Framework/Api/Controller/ApiController.php",
                        "line": 454,
                        "function": "write",
                        "class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxx/vendor/symfony/http-kernel/HttpKernel.php",
                        "line": 152,
                        "function": "create",
                        "class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
                        "type": "->"
                    },
                    {
                        "file": "/xxxx/vendor/symfony/http-kernel/HttpKernel.php",
                        "line": 74,
                        "function": "handleRaw",
                        "class": "Symfony\\Component\\HttpKernel\\HttpKernel",
                        "type": "->"
                    },
                    {
                        "file": "/xxxx/vendor/symfony/http-kernel/Kernel.php",
                        "line": 202,
                        "function": "handle",
                        "class": "Symfony\\Component\\HttpKernel\\HttpKernel",
                        "type": "->"
                    },
                    {
                        "file": "/xxxx/vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php",
                        "line": 86,
                        "function": "handle",
                        "class": "Symfony\\Component\\HttpKernel\\Kernel",
                        "type": "->"
                    },
                    {
                        "file": "/xxx/vendor/symfony/http-kernel/HttpCache/HttpCache.php",
                        "line": 479,
                        "function": "handle",
                        "class": "Symfony\\Component\\HttpKernel\\HttpCache\\SubRequestHandler",
                        "type": "::"
                    },
                    {
                        "file": "/xxxxxx/vendor/symfony/http-kernel/HttpCache/HttpCache.php",
                        "line": 269,
                        "function": "forward",
                        "class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxx/vendor/symfony/http-kernel/HttpCache/HttpCache.php",
                        "line": 285,
                        "function": "pass",
                        "class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxxx/vendor/symfony/http-kernel/HttpCache/HttpCache.php",
                        "line": 213,
                        "function": "invalidate",
                        "class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxx/vendor/shopware/core/HttpKernel.php",
                        "line": 153,
                        "function": "handle",
                        "class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxxx/vendor/shopware/core/HttpKernel.php",
                        "line": 79,
                        "function": "doHandle",
                        "class": "Shopware\\Core\\HttpKernel",
                        "type": "->"
                    },
                    {
                        "file": "/xxxxx/public/index.php",
                        "line": 74,
                        "function": "handle",
                        "class": "Shopware\\Core\\HttpKernel",
                        "type": "->"
                    }
                ],
                "file": "xxx/vendor/shopware/core/Framework/DataAbstractionLayer/Write/DataStack/KeyValuePair.php",
                "line": 22
            }
        }
    ]
}

```

Cache habe ich geleert beim umstellen auf dev.  
Danke!

---

<div class="post-metadata">

**Author:** ![abdullah](https://avatars.discourse-cdn.com/v4/letter/a/aeb1de/32.png) [@abdullah](https://forum.shopware.com/u/abdullah)\
**Post date:** [29. Juni 2022 um 06:32 UTC](https://forum.shopware.com/t/http-500-nach-api-post-request-auf-customer/95017/6 "2022-06-29T06:32:56Z")

</div>

@ayti, der Fehler wird durch ein ManyToOneAssociationField verursacht.  
Bei dir kommen da die Adressen in Frage.

Sehe gerade auch, dass du den Adressen ein Array mit gibst. Die defaultBillingAddress und defaultShippingAddress sind keine Arrays sondern Entitäten.  
Hier sollte es ausreichen die eckigen Klammern zu entfernen.

vg

---

<div class="post-metadata">

**Author:** ![ayti](https://avatars.discourse-cdn.com/v4/letter/a/cab0a1/32.png) [@ayti](https://forum.shopware.com/u/ayti)\
**Post date:** [29. Juni 2022 um 14:55 UTC](https://forum.shopware.com/t/http-500-nach-api-post-request-auf-customer/95017/7 "2022-06-29T14:55:57Z")

</div>

@abdullah, danke! Genau daran hats gelegen, total vergessen das es eine Entität ist. Danke!
