# How to create an order with the Admin API?

**URL:** https://forum.shopware.com/t/how-to-create-an-order-with-the-admin-api/87285
**Category:** General Questions (EN)
**Tags:** programming
**Created:** [29. April 2021 um 09:32 UTC](https://forum.shopware.com/t/how-to-create-an-order-with-the-admin-api/87285 "2021-04-29T09:32:59Z")
**Posts on this page:** 6
**Page:** 1

<div class="post-metadata">

### Author: ![Thibaux](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@Thibaux](https://forum.shopware.com/u/Thibaux)
#### Post date: [29. April 2021 um 09:32 UTC](https://forum.shopware.com/t/how-to-create-an-order-with-the-admin-api/87285/1 "2021-04-29T09:32:59Z")

</div>

Hey!

At the moment I’m trying to post a order to a local Shopware 6 store, with my php application and using the Admin API.

To achieve this I’m using the following endpoint:  
[http://127.0.0.1/api/v3/order](http://127.0.0.1/api/v3/order)

This is the error I’m receiving:  
{  
„errors“: [  
{  
„code“: „0“,  
„status“: „500“,  
„title“: „Internal Server Error“,  
„detail“: „Argument 1 passed to Shopware\Core\Checkout\Cart\Price\Struct\ReferencePrice::\_\_construct() must be of the type float, null given, called in /var/www/html/vendor/shopware/core/Framework/DataAbstractionLayer/FieldSerializer/CalculatedPriceFieldSerializer.php on line 73“  
}  
]  
}

I cannot go into the code and fix this error in my Shopware 6 instance, because then my clients would have to do that as well.

**Can I insert a order in a Shopware 6 store with the Admin API, if so could you tell me how?**

Thanks in advance!

Please find my request body below:  
{  
„billingAddressId“: „3fa85f6457174562b3fc2c963f66afa6“,  
„billingAddressVersionId“: „3fa85f6457174562b3fc2c963f66afa6“,  
„currencyId“: „0dd28674b6ce471fbea53c7178d538ab“,  
„languageId“: „0e469be3c1b648f598f0adddb517b79f“,  
„salesChannelId“: „98432def39fc4624b33213a56b8c944d“,  
„stateId“: „3fa85f6457174562b3fc2c963f66afa6“,  
„orderDateTime“: „2021-04-28T20:13:51.176Z“,  
„type“: „string“,  
„id“: „3fa85f6457174562b3fc2c963f66afa6“,  
„attributes“: {  
„additionalProp1“: {}  
},  
„relationships“: {  
„stateMachineState“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/stateMachineState“  
},  
„data“: {  
„type“: „state\_machine\_state“,  
„id“: „038e940c44da4b17b1d254deba448f84“  
}  
},  
„orderCustomer“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/orderCustomer“  
},  
„data“: {  
„type“: „order\_customer“,  
„id“: „800d42ebaea24d2497fd67d0adfd4240“  
}  
},  
„currency“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/currency“  
},  
„data“: {  
„type“: „currency“,  
„id“: „1859cba627744ca789828271a04d0ef0“  
}  
},  
„language“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/language“  
},  
„data“: {  
„type“: „language“,  
„id“: „07196ed0209f420091482f1aa4e35e9c“  
}  
},  
„salesChannel“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/salesChannel“  
},  
„data“: {  
„type“: „sales\_channel“,  
„id“: „ec6d3d4b39054eaf8fcdcf4231e0b583“  
}  
},  
„addresses“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/addresses“  
},  
„data“: [  
{  
„type“: „order\_address“,  
„id“: „aad0921f637a474bb4803f13dc580321“  
}  
]  
},  
„deliveries“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/deliveries“  
},  
„data“: [  
{  
„type“: „order\_delivery“,  
„id“: „f2827017d2784b1d8e7206d731e2eec1“  
}  
]  
},  
„lineItems“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/lineItems“  
},  
„data“: [  
{  
„type“: „order\_line\_item“,  
„id“: „8a05ae2d58314768822db96353bc57a4“  
}  
]  
},  
„transactions“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/transactions“  
},  
„data“: [  
{  
„type“: „order\_transaction“,  
„id“: „ccb57554dff54d8caa1b4f03b35d0f72“  
}  
]  
},  
„documents“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/documents“  
},  
„data“: [  
{  
„type“: „document“,  
„id“: „c5e62f9ac2f74f24b5f5321753dd1ade“  
}  
]  
},  
„tags“: {  
„links“: {  
„related“: „/order/884e6f39e1db422fa0e7a07d09de761d/tags“  
},  
„data“: [  
{  
„type“: „tag“,  
„id“: „ead585deebe248f28ac6dcdd65ff3c82“  
}  
]  
}  
},  
„links“: {},  
„meta“: {  
„additionalProp1“: {}  
},  
„price“: {  
„netPrice“: 0,  
„totalPrice“: 0,  
„calculatedTaxes“: {},  
„taxRules“: {},  
„positionPrice“: 0,  
„taxStatus“: „string“  
},  
„shippingCosts“: {  
„unitPrice“: 0,  
„totalPrice“: 0,  
„quantity“: 0,  
„calculatedTaxes“: {},  
„taxRules“: {},  
„referencePrice“: {},  
„listPrice“: {  
„price“: 0,  
„discount“: 0,  
„percentage“: 0  
}  
},  
„currencyFactor“: 0,  
„deepLinkCode“: „string“,  
„affiliateCode“: „string“,  
„campaignCode“: „string“,  
„customerComment“: „string“,

```
"customFields": {}

```

}

---

<div class="post-metadata">

### Author: ![timbrns](https://dub1.discourse-cdn.com/flex013/user_avatar/forum.shopware.com/timbrns/32/19740_2.png) [@timbrns](https://forum.shopware.com/u/timbrns)
#### Post date: [30. April 2021 um 07:37 UTC](https://forum.shopware.com/t/how-to-create-an-order-with-the-admin-api/87285/2 "2021-04-30T07:37:54Z")

</div>

Hello @Thibaux,  
you can find a documentation about using the API from one of our developers here:  
[https://swagger.docs.fos.gg/?urls.primaryName=Management%20API%20(6.3.5.4)#/Order](https://swagger.docs.fos.gg/?urls.primaryName=Management%20API%20(6.3.5.4)#/Order)

If you are using the newest version of Shopware 6 you should also use the Management API over the admin API.

Kind regards,   
 Tim Bruns

---

<div class="post-metadata">

### Author: ![Thibaux](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@Thibaux](https://forum.shopware.com/u/Thibaux)
#### Post date: [30. April 2021 um 12:42 UTC](https://forum.shopware.com/t/how-to-create-an-order-with-the-admin-api/87285/3 "2021-04-30T12:42:02Z")

</div>

Hey Tim!

Thanks so much for you answer. Thank you for the link to the Swagger doc, I found that one all ready, I used it in my body. Could you please show me the difference between the Management- and the Admin API? I can’t find any documentation on a Shopware Management API.

Below I have included the body fields that are required. And the response that I’m receiving. Do you see anything wrong?

Your help is really appreciated!

RESPONSE:  
{  
„errors“: [  
{  
„code“: „0“,  
„status“: „500“,  
„title“: „Internal Server Error“,  
„detail“: „Argument 1 passed to Shopware\Core\Framework\Struct\Collection::\_\_construct() must be iterable, null given, called in /var/www/html/vendor/shopware/core/Framework/DataAbstractionLayer/FieldSerializer/CartPriceFieldSerializer.php on line 65“  
}  
]  
}

BODY:  
{  
„billingAddressId“: „3fa85f6457174562b3fc2c963f66afa6“,  
„currencyId“: „0dd28674b6ce471fbea53c7178d538ab“,  
„languageId“: „0e469be3c1b648f598f0adddb517b79f“,  
„salesChannelId“: „938be4f9e2b24b97b709a8f3b647d3de“,  
„orderDateTime“: „2021-04-28T20:20:38.722Z“,  
„price“: {  
„netPrice“: 47.3519,  
„totalPrice“: 50.32,  
„positionPrice“: 50.32,  
„taxStatus“: „gross“  
},  
„currencyFactor“: 0,  
„stateId“: „3fa85f6457174562b3fc2c963f66afa6“,  
„createdAt“: „2021-04-11T20:20:38.722Z“,  
„shippingCosts“: {  
„unitPrice“: 50.32,  
„totalPrice“: 50.32,  
„quantity“: 0  
}  
}

---

<div class="post-metadata">

### Author: ![p.jager](https://avatars.discourse-cdn.com/v4/letter/p/4bbf92/32.png) [@p.jager](https://forum.shopware.com/u/p.jager)
#### Post date: [22. Juni 2021 um 09:49 UTC](https://forum.shopware.com/t/how-to-create-an-order-with-the-admin-api/87285/4 "2021-06-22T09:49:15Z")

</div>

Hi did you manage to get it working?

I am trying the same thing, creating an order using the api on a new demo shop (\>= v4).  
Just resolved all the errors and I got

Body:  
{  
„affiliateCode“: null,  
„apiAlias“: null,  
„billingAddressId“: „8141fc15a08248fa960448ae0a5c7bae“,  
„campaignCode“: null,  
„currencyFactor“: 1,  
„currencyId“: „b7d2554b0ce847cd82f3ac9bd1c0dfca“,  
„customFields“: null,  
„customerComment“: null,  
„languageId“: „2fbb5fe2e29a4d70aa5854ce7ce3e20b“,  
„orderDateTime“: „2021-05-07T12:59:34.663+00:00“,  
„price“: {  
„rawTotal“: 20,  
„taxStatus“: „gross“,  
„calculatedTaxes“: [  
{  
„extensions“: ,  
„price“: 20,  
„tax“: 0,  
„taxRate“: 0  
}  
],  
„extensions“: ,  
„netPrice“: 20,  
„positionPrice“: 20,  
„taxRules“: [  
{  
„extensions“: ,  
„percentage“: 100,  
„taxRate“: 0  
}  
],  
„totalPrice“: 20  
},  
„salesChannelId“: „98432def39fc4624b33213a56b8c944d“,  
„shippingCosts“: {  
„calculatedTaxes“: [  
{  
„extensions“: ,  
„price“: 0,  
„tax“: 0,  
„taxRate“: 0  
}  
],  
„extensions“: ,  
„listPrice“: null,  
„quantity“: 1,  
„referencePrice“: null,  
„taxRules“: [  
{  
„extensions“: ,  
„percentage“: 100,  
„taxRate“: 0  
}  
],  
„totalPrice“: 0,  
„unitPrice“: 0  
},  
„stateId“: „55d3558bfd4a4cd18f3c68d862b7ba17“,  
„updatedAt“: null,  
„meta“: null,  
„type“: „order“  
}

Response:  
…

```
		<h3 class="sw-saas-error-page__title">Error</h3>

		<p>Something went seriously wrong!</p>
		<p>Try again later.
		</p>
	</div>

```

…

Same result using your body (with my own UUID’s).

This broke the order overview in the backend of my backend ☹

---

<div class="post-metadata">

### Author: ![Thibaux](https://avatars.discourse-cdn.com/v4/letter/t/e0b2c6/32.png) [@Thibaux](https://forum.shopware.com/u/Thibaux)
#### Post date: [22. Juni 2021 um 13:55 UTC](https://forum.shopware.com/t/how-to-create-an-order-with-the-admin-api/87285/5 "2021-06-22T13:55:18Z")

</div>

Hey,

Sadly no, however I did manage to create an order with the Store API.  
I used this documentation: [Shopware Store API | Store API](https://shopware.stoplight.io/docs/store-api/storeapi.json)

To get this working I needed to make a lot of calls, see below:  
 ![image](https://europe1.discourse-cdn.com/flex013/uploads/shopware/original/2X/f/fd0a1253fb9ecd14ce29dc2da536829c20be336f.png)

The endpoints and request bodys for these calls are shown in the documentation above.

If you would like to do this: don’t forget that you need to use the contextToken that you recive from the login call to use with the other calls.

Succes!

---

<div class="post-metadata">

### Author: ![lauriecampbell1981](https://avatars.discourse-cdn.com/v4/letter/l/e36b37/32.png) [@lauriecampbell1981](https://forum.shopware.com/u/lauriecampbell1981)
#### Post date: [1. Juli 2021 um 06:20 UTC](https://forum.shopware.com/t/how-to-create-an-order-with-the-admin-api/87285/6 "2021-07-01T06:20:16Z")

</div>

Thanks for update and quick reply. I’ll be sure to keep an eye on this thread. looking for the same issue.

[www.targetpayandbenefits.com](https://www.targetpayandbenefits.review/)
