我正在尝试通过管理 API 在 Shopware6 中创建订单
我的 Json 对象:
// POST https://myserver.example.com/api/v3/order
{
"currencyId": "b7d2554b0ce847cd82f3ac9bd1c0dfca",
"salesChannelId": "ed47859020cc46349ed5f024c65d09e5",
"billingAddressId": "629002cceec64dd888b4c52b782d6427",
"stateId": "9c22101c81d14eb9be55a93a3ba39aa2",
"languageId": "2fbb5fe2e29a4d70aa5854ce7ce3e20b",
"currencyFactor": 1,
"orderCustomer": {
"email": "abc@xyz.com",
"salutationId": "1354f03b5d7c414e8b5aaddd0a32e8ca",
"firstName": "Donald",
"lastName": "Duck",
"customerNumber": "10045",
"customerId": "9432a62c65ae4bcbb335c3bc853d79e8",
"remoteAddress": "10.147.19.0"
},
"price": {
"netPrice": 33.57,
"totalPrice": 39.95,
"calculatedTaxes": [{
"tax": 6.38,
"taxRate": 19,
"price": 39.95
}],
"taxRules": [{
"taxRate": 19,
"percentage": 100
}],
"positionPrice": 39.95,
"taxStatus": "gross"
},
"orderDateTime": "2021-04-21T14:27:57.006+0000",
"createdAt": "2021-04-21T14:27:57.056+0000",
"lineItems": [{
"identifier": "8c380f63883449adec1ee4ccb456c489",
"quantity": 1,
"label": "Handtasche - Designer Bag",
"type": "product",
"good": true,
"removable": true,
"stackable": true,
"position": 1,
"price": {
"unitPrice": 39.95,
"quantity": 1,
"totalPrice": 39.95,
"calculatedTaxes": [{
"tax": 6.38,
"taxRate": 19,
"price": 39.95
}],
"taxRules": [{
"taxRate": 19,
"percentage": 100
}]
},
"createdAt": "2021-04-21T14:27:57.054+0000"
}]
}
但这给了我回应:
{
"errors": [{
"code": "0",
"status": "500",
"title": "Internal Server Error",
"detail": "Notice: Trying to access array offset on value of type null",
"meta": {
"trace": [{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/Dbal\/EntityHydrator.php",
"line": 213,
"function": "decode",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\FieldSerializer\\CalculatedPriceFieldSerializer",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/Dbal\/EntityHydrator.php",
"line": 49,
"function": "hydrateEntity",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Dbal\\EntityHydrator",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/Dbal\/EntityReader.php",
"line": 126,
"function": "hydrate",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Dbal\\EntityHydrator",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/Dbal\/EntityReader.php",
"line": 94,
"function": "_read",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Dbal\\EntityReader",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/Cache\/CachedEntityReader.php",
"line": 130,
"function": "read",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Dbal\\EntityReader",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/Cache\/CachedEntityReader.php",
"line": 55,
"function": "loadResultByIds",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Cache\\CachedEntityReader",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Profiling\/Entity\/EntityReaderProfiler.php",
"line": 36,
"function": "read",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Cache\\CachedEntityReader",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/EntityRepository.php",
"line": 239,
"function": "read",
"class": "Shopware\\Core\\Profiling\\Entity\\EntityReaderProfiler",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/EntityRepository.php",
"line": 91,
"function": "read",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Checkout\/Customer\/Subscriber\/CustomerMetaFieldSubscriber.php",
"line": 62,
"function": "search",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/event-dispatcher\/EventDispatcher.php",
"line": 304,
"function": "fillCustomerMetaDataFields",
"class": "Shopware\\Core\\Checkout\\Customer\\Subscriber\\CustomerMetaFieldSubscriber",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/event-dispatcher\/EventDispatcher.php",
"line": 251,
"function": "Symfony\\Component\\EventDispatcher\\{closure}",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "::"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/event-dispatcher\/EventDispatcher.php",
"line": 73,
"function": "callListeners",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/Webhook\/WebhookDispatcher.php",
"line": 88,
"function": "dispatch",
"class": "Symfony\\Component\\EventDispatcher\\EventDispatcher",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/Event\/BusinessEventDispatcher.php",
"line": 46,
"function": "dispatch",
"class": "Shopware\\Core\\Framework\\Webhook\\WebhookDispatcher",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/Event\/NestedEventDispatcher.php",
"line": 32,
"function": "dispatch",
"class": "Shopware\\Core\\Framework\\Event\\BusinessEventDispatcher",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/Event\/NestedEventDispatcher.php",
"line": 28,
"function": "dispatch",
"class": "Shopware\\Core\\Framework\\Event\\NestedEventDispatcher",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/event-dispatcher\/Debug\/TraceableEventDispatcher.php",
"line": 168,
"function": "dispatch",
"class": "Shopware\\Core\\Framework\\Event\\NestedEventDispatcher",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/EntityRepository.php",
"line": 178,
"function": "dispatch",
"class": "Symfony\\Component\\EventDispatcher\\Debug\\TraceableEventDispatcher",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/Api\/Controller\/ApiController.php",
"line": 916,
"function": "create",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/Context.php",
"line": 183,
"function": "Shopware\\Core\\Framework\\Api\\Controller\\{closure}",
"class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/Api\/Controller\/ApiController.php",
"line": 934,
"function": "scope",
"class": "Shopware\\Core\\Framework\\Context",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/Api\/Controller\/ApiController.php",
"line": 780,
"function": "executeWriteOperation",
"class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/Api\/Controller\/ApiController.php",
"line": 452,
"function": "write",
"class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/http-kernel\/HttpKernel.php",
"line": 158,
"function": "create",
"class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/http-kernel\/HttpKernel.php",
"line": 80,
"function": "handleRaw",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/http-kernel\/Kernel.php",
"line": 201,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/http-kernel\/HttpCache\/SubRequestHandler.php",
"line": 85,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\Kernel",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php",
"line": 477,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\SubRequestHandler",
"type": "::"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php",
"line": 267,
"function": "forward",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php",
"line": 283,
"function": "pass",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/symfony\/http-kernel\/HttpCache\/HttpCache.php",
"line": 211,
"function": "invalidate",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/HttpKernel.php",
"line": 163,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/HttpKernel.php",
"line": 80,
"function": "doHandle",
"class": "Shopware\\Core\\HttpKernel",
"type": "-\u003E"
},
{
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/public\/index.php",
"line": 83,
"function": "handle",
"class": "Shopware\\Core\\HttpKernel",
"type": "-\u003E"
}],
"file": "\/data\/srv\/myserver.example.com\/www\/releases\/0.0\/vendor\/shopware\/core\/Framework\/DataAbstractionLayer\/FieldSerializer\/CalculatedPriceFieldSerializer.php",
"line": 51
}
}]
我用“价格”对象尝试了各种不同的变体,计算了税金,没有任何我想到的东西,都没有成功。
一个正确的 JSON 对象如何成功创建订单?