# Alle Bestelldaten aus einer Bestellung via API (RestSharp)

**URL:** <https://forum.shopware.com/t/alle-bestelldaten-aus-einer-bestellung-via-api-restsharp/98360>\
**Category:** Shopware 6 (German)\
**Created:** [5. Februar 2023 um 23:32 UTC](https://forum.shopware.com/t/alle-bestelldaten-aus-einer-bestellung-via-api-restsharp/98360 "2023-02-05T23:32:12Z")\
**Posts on this page:** 4\
**Page:** 1

<div class="post-metadata">

**Author:** ![rotknecht](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rotknecht](https://forum.shopware.com/u/rotknecht)\
**Post date:** [5. Februar 2023 um 23:32 UTC](https://forum.shopware.com/t/alle-bestelldaten-aus-einer-bestellung-via-api-restsharp/98360/1 "2023-02-05T23:32:12Z")

</div>

Hallo,

ich probiere gerade mit der API herum und möchte eine bestimmte Bestellung mit allen Details erhalten.

Ich nutze [VB.NET](http://VB.NET) und RestSharp.

Die Hauptdaten der Bestellung habe ich bereits erhalten:

```auto
        Dim client As New RestClient(URL)
        Dim request As New RestRequest("/order/" & ID, Method.Get)
        Dim response As New RestResponse

        request.AddUrlSegment("id", "order_id")
        request.AddHeader("Authorization", "Bearer " & Token.bearerToken)

        response = client.Execute(request)

        Dim order As String = response.Content

```

Leider sind in den Daten keine weiteren Detaildaten zur Bestellung drin (Adresse, Lieferadresse, Positionen, Zahlungsart).

Kann man das auch in „einem Rutsch“ mit erhalten?  
Oder muss man diese Daten mit separaten API-Aufrufen abfragen? Wenn ja, wo findet man dann die entsprechenden IDs (zum Beispiel für die Adresse?)

---

<div class="post-metadata">

**Author:** ![HardyPaw](https://avatars.discourse-cdn.com/v4/letter/h/82dd89/32.png) [@HardyPaw](https://forum.shopware.com/u/HardyPaw)\
**Post date:** [10. Februar 2023 um 13:35 UTC](https://forum.shopware.com/t/alle-bestelldaten-aus-einer-bestellung-via-api-restsharp/98360/2 "2023-02-10T13:35:56Z")

</div>

Hallo,

das kann mit den Associations gelöst werden.

Beispiel: Request\_Body

{  
„ids“: „f0c70188f4b042d986d8c9d53121005f“,  
„page“: 1,  
„limit“: 25,  
„associations“: {  
„lineItems“: {  
„associations“: {  
„product“: {}  
}  
},  
„currency“: {},  
„language“: {},  
„orderCustomer“: {  
„associations“: {  
„customer“: {}  
}  
},  
„salesChannel“: {  
„associations“: {}  
},  
„addresses“: {  
„associations“: {  
„country“: {},  
„countryState“: {},  
„salutation“: {}  
}  
},  
„deliveries“: {  
„associations“: {  
„shippingMethod“: {},  
„shippingOrderAddress“: {}  
}  
},  
„transactions“: {  
„associations“: {  
„paymentMethod“: {}  
}  
},  
„documents“: {  
„associations“: {  
„documentType“: {}  
}  
},  
„tags“: {}  
}  
}

Grüße

---

<div class="post-metadata">

**Author:** ![rotknecht](https://avatars.discourse-cdn.com/v4/letter/r/b5ac83/32.png) [@rotknecht](https://forum.shopware.com/u/rotknecht)\
**Post date:** [16. Februar 2023 um 18:29 UTC](https://forum.shopware.com/t/alle-bestelldaten-aus-einer-bestellung-via-api-restsharp/98360/3 "2023-02-16T18:29:35Z")

</div>

Hättest du vielleicht ein Beispiel, wie man das in restsharp abbildet?

---

<div class="post-metadata">

**Author:** ![HardyPaw](https://avatars.discourse-cdn.com/v4/letter/h/82dd89/32.png) [@HardyPaw](https://forum.shopware.com/u/HardyPaw)\
**Post date:** [1. März 2023 um 15:20 UTC](https://forum.shopware.com/t/alle-bestelldaten-aus-einer-bestellung-via-api-restsharp/98360/4 "2023-03-01T15:20:57Z")

</div>

Hallo,

die Associations können mit ExpandoObject aus System.Dynamic gebildet und dann serialisiert werden.

```
    public async Task<Order> Get_Order(string id, string languageid = "")
    {
        if (string.IsNullOrEmpty(languageid)) languageid = ShopLanguageId;

        // Associations Struktur anlegen
        dynamic associations = new ExpandoObject();

        associations.lineItems = new ExpandoObject();
        associations.lineItems.associations = new ExpandoObject();
        associations.lineItems.associations.product = new ExpandoObject();
        if (IVersion.CompareTo(new Version("6.4.10.0")) > 0) associations.lineItems.associations.children = new ExpandoObject();

        associations.currency = new ExpandoObject();
        associations.language = new ExpandoObject();

        associations.orderCustomer = new ExpandoObject();
        associations.orderCustomer.associations = new ExpandoObject();
        associations.orderCustomer.associations.customer = new ExpandoObject();

        associations.salesChannel = new ExpandoObject();
        associations.salesChannel.associations = new ExpandoObject();

        associations.addresses = new ExpandoObject();
        associations.addresses.associations = new ExpandoObject();
        associations.addresses.associations.country = new ExpandoObject();
        associations.addresses.associations.countryState = new ExpandoObject();
        associations.addresses.associations.salutation = new ExpandoObject();

        associations.deliveries = new ExpandoObject();
        associations.deliveries.associations = new ExpandoObject();
        associations.deliveries.associations.shippingMethod = new ExpandoObject();
        associations.deliveries.associations.shippingOrderAddress = new ExpandoObject();

        associations.transactions = new ExpandoObject();
        associations.transactions.associations = new ExpandoObject();
        associations.transactions.associations.paymentMethod = new ExpandoObject();

        associations.documents = new ExpandoObject();
        associations.documents.associations = new ExpandoObject();
        associations.documents.associations.documentType = new ExpandoObject();

        associations.tags = new ExpandoObject();

        Search JParam = new Search { Ids = new List<string> { id }, Page = 1, Limit = 25, Associations = associations };

        string @apisource = $@"/api{apiversionstr}/search/order";

        RestRequest request = new RestRequest(apisource) { Method = Method.Post }
          .AddHeader("sw-language-id", languageid)
          .AddStringBody(JsonConvert.SerializeObject(JParam, Formatting.Indented, NoEmpties), DataFormat.Json);

        RestResponse response = await CallRest(Base_url, request);

```

CallRest führt letzendlich RestClient.ExecutePostAsync(request) aus.
