# Produkt per API anlegen

**URL:** <https://forum.shopware.com/t/produkt-per-api-anlegen/104151>\
**Category:** Programmierung\
**Created:** [30. Mai 2024 um 07:56 UTC](https://forum.shopware.com/t/produkt-per-api-anlegen/104151 "2024-05-30T07:56:35Z")\
**Posts on this page:** 2\
**Page:** 1

<div class="post-metadata">

**Author:** ![webarbeit](https://avatars.discourse-cdn.com/v4/letter/w/b487fb/32.png) [@webarbeit](https://forum.shopware.com/u/webarbeit)\
**Post date:** [30. Mai 2024 um 07:56 UTC](https://forum.shopware.com/t/produkt-per-api-anlegen/104151/1 "2024-05-30T07:56:35Z")

</div>

Guten Morgen zusammen,

ich versuche gerade ein Produkt per API anzulegen. Grundsätzlich funktioniert die Kommunikation mit der API, nur das Anlegen von Produkten klappt nicht.

Es kommt die Meldung, dass mein Payload leer sei.

Payload als Array:

```auto
Array
(
    [name] => test2
    [productNumber] => random2
    [stock] => 10
    [taxId] => 018f5769b77e708888cbb8f9623ab918
    [price] => Array
        (
            [currencyId] => b7d2554b0ce847cd82f3ac9bd1c0dfca
            [gross] => 15
            [net] => 10
            [linked] => 
        )

)

```

Payload als JSON:

```auto
{"name":"test2","productNumber":"random2","stock":10,"taxId":"018f5769b77e708888cbb8f9623ab918","price":{"currencyId":"b7d2554b0ce847cd82f3ac9bd1c0dfca","gross":15,"net":10,"linked":false}}

```

Übergabe an curl:

```auto
    curl_setopt_array($curl, [
        CURLOPT_URL => $url . "/api/product",
        CURLOPT_RETURNTRANSFER => true,
        CURLOPT_ENCODING => "",
        CURLOPT_MAXREDIRS => 10,
        CURLOPT_TIMEOUT => 600,
        CURLOPT_HTTP_VERSION => CURL_HTTP_VERSION_1_1,
        CURLOPT_CUSTOMREQUEST => "POST",
        CURLOPT_POST => true,
        CURLOPT_POSTFIELDS => $payload,
        CURLOPT_HTTPHEADER => [
            "authorization: Bearer ".$access_token."",
            "content-type: application/json"
        ],
        CURLOPT_SSL_VERIFYPEER => false,
    ]);

```

Hat jemand eine Idee, einen Hinweis wo der Fehler liegen könnte? Benötigt Ihr weitere Informationen?

Vielen Dank vorab und Grüße,  
Frank

---

<div class="post-metadata">

**Author:** ![AlexGalax](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/alexgalax/32/9925_2.png) [@AlexGalax](https://forum.shopware.com/u/AlexGalax)\
**Post date:** [4. Juni 2024 um 02:30 UTC](https://forum.shopware.com/t/produkt-per-api-anlegen/104151/2 "2024-06-04T02:30:07Z")

</div>

1. Schau dir die Response an, da sollte drin stehen was falsch ist.
2. Ich vermute es wird eine fehlende Produkt–Id sein. Ids sind kein Auto–Increment mehr, und werden demnach nicht automatisch erzeugt. Generiere am besten [uuid v7](https://idtools.co/uuid/v7).
