How to create an order in Shopware6 via API? - shopware

I am trying to create an order in Shopware6 via the Admin API
My Json Object:
// 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"
}]
}
But this gives me the Response:
{
"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
}
}]
I tried all kinds of different variations with the "price" object, with calculated taxes, without and anything that came to my mind, no success.
How would a correct JSON object look like that successfully creates an order?

When I work with the API, sometimes I just create an entity manually (e.g. Order) & then try to GET it via the API. Then you can just copy the formatting and feed it back to your POST call.
You might be missing "rawTotal": 468.55 in your main price object.
That said, the error suggests that the value should be an array, but it is not set. They don't use version numbers in their API anymore, so maybe this is no longer relevant :)

Related

OrderDelivery requires shippingCosts even though it should not according to the documentation Shopware 6 Admin API

I am trying to create a new OrderDelivery entry using the Shopware Admin API. To do this I am using this api. According to the documentation it should not be required to supply the field shippingCosts, but when I send my request
{ "trackingCode": [ "328432328" ], "shippingMethodId": "THE_ID_OF_THE_SHIPPING_METHOD", "shippingOrderAddressId": "THE_ADDRESS_ID", "stateId": "THE_STATE_ID", "shippingDateEarliest": "2022-07-07T00:00:00.000+00:00", "shippingDateLatest": "2022-07-07T00:00:00.000+00:00" }
via POST to https://myshopwareinstance/api/order/ORDER_ID/deliveries, I receive a 500 Error response code. The response looks like this:
{
"errors": [
{
"code": "0",
"status": "500",
"title": "Internal Server Error",
"detail":"An exception occurred while executing 'INSERT INTO `order_delivery` (`id`, `version_id`, `order_id`, `order_version_id`, `shipping_order_address_id`, `shipping_order_address_version_id`, `shipping_method_id`, `state_id`, `tracking_codes`, `shipping_date_earliest`, `shipping_date_latest`, `created_at`) VALUES ('���9hL?��Y�F]m�','���jK¾K��u,4%','\u000b���aBF�����z�','���jK¾K��u,4%','��L�!F[���$KU��','���jK¾K��u,4%','���7K���X�&�� ','IA��XJ*�4���\\\"�','[]','2022-07-12 00:00:00.000','2022-07-12 00:00:00.000','2022-07-19 08:52:42.928');':\n\nSQLSTATE[HY000]: General error: 1364 Field 'shipping_costs' doesn't have a default value",
"meta": {
"trace": [
{
"file": "/shopwaredir/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php",
"line": 182,
"function": "convertException",
"class": "Doctrine\\DBAL\\Driver\\AbstractMySQLDriver",
"type": "->"
},
{
"file": "/shopwaredir/vendor/doctrine/dbal/lib/Doctrine/DBAL/DBALException.php",
"line": 159,
"function": "wrapException",
"class": "Doctrine\\DBAL\\DBALException",
"type": "::"
},
{
"file": "/shopwaredir/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",
"line": 2226,
"function": "driverExceptionDuringQuery",
"class": "Doctrine\\DBAL\\DBALException",
"type": "::"
},
{
"file": "/shopwaredir/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",
"line": 1538,
"function": "handleExceptionDuringQuery",
"class": "Doctrine\\DBAL\\Connection",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Doctrine/MultiInsertQueryQueue.php",
"line": 89,
"function": "executeStatement",
"class": "Doctrine\\DBAL\\Connection",
"type": "->"
},
{
"file": "/shopwaredir/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",
"line": 1670,
"function": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Doctrine\\{closure}",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Doctrine\\MultiInsertQueryQueue",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Doctrine/RetryableTransaction.php",
"line": 30,
"function": "transactional",
"class": "Doctrine\\DBAL\\Connection",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Doctrine/RetryableTransaction.php",
"line": 19,
"function": "retry",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Doctrine\\RetryableTransaction",
"type": "::"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Doctrine/MultiInsertQueryQueue.php",
"line": 91,
"function": "retryable",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Doctrine\\RetryableTransaction",
"type": "::"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Dbal/EntityWriteGateway.php",
"line": 245,
"function": "execute",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Doctrine\\MultiInsertQueryQueue",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Dbal/EntityWriteGateway.php",
"line": 141,
"function": "executeCommands",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Dbal\\EntityWriteGateway",
"type": "->"
},
{
"file": "/shopwaredir/vendor/doctrine/dbal/lib/Doctrine/DBAL/Connection.php",
"line": 1670,
"function": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Dbal\\{closure}",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Dbal\\EntityWriteGateway",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Doctrine/RetryableTransaction.php",
"line": 30,
"function": "transactional",
"class": "Doctrine\\DBAL\\Connection",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Doctrine/RetryableTransaction.php",
"line": 19,
"function": "retry",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Doctrine\\RetryableTransaction",
"type": "::"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Dbal/EntityWriteGateway.php",
"line": 142,
"function": "retryable",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Doctrine\\RetryableTransaction",
"type": "::"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Write/EntityWriter.php",
"line": 207,
"function": "execute",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Dbal\\EntityWriteGateway",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/Write/EntityWriter.php",
"line": 143,
"function": "write",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\EntityWriter",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/VersionManager.php",
"line": 118,
"function": "insert",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\Write\\EntityWriter",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/DataAbstractionLayer/EntityRepository.php",
"line": 157,
"function": "insert",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\VersionManager",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/Api/Controller/ApiController.php",
"line": 916,
"function": "create",
"class": "Shopware\\Core\\Framework\\DataAbstractionLayer\\EntityRepository",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/Context.php",
"line": 207,
"function": "Shopware\\Core\\Framework\\Api\\Controller\\{closure}",
"class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/Api/Controller/ApiController.php",
"line": 934,
"function": "scope",
"class": "Shopware\\Core\\Framework\\Context",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/Api/Controller/ApiController.php",
"line": 818,
"function": "executeWriteOperation",
"class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/Framework/Api/Controller/ApiController.php",
"line": 454,
"function": "write",
"class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
"type": "->"
},
{
"file": "/shopwaredir/vendor/symfony/http-kernel/HttpKernel.php",
"line": 152,
"function": "create",
"class": "Shopware\\Core\\Framework\\Api\\Controller\\ApiController",
"type": "->"
},
{
"file": "/shopwaredir/vendor/symfony/http-kernel/HttpKernel.php",
"line": 74,
"function": "handleRaw",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->"
},
{
"file": "/shopwaredir/vendor/symfony/http-kernel/Kernel.php",
"line": 202,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\HttpKernel",
"type": "->"
},
{
"file": "/shopwaredir/vendor/symfony/http-kernel/HttpCache/SubRequestHandler.php",
"line": 86,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\Kernel",
"type": "->"
},
{
"file": "/shopwaredir/vendor/symfony/http-kernel/HttpCache/HttpCache.php",
"line": 479,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\SubRequestHandler",
"type": "::"
},
{
"file": "/shopwaredir/vendor/symfony/http-kernel/HttpCache/HttpCache.php",
"line": 269,
"function": "forward",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
"type": "->"
},
{
"file": "/shopwaredir/vendor/symfony/http-kernel/HttpCache/HttpCache.php",
"line": 285,
"function": "pass",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
"type": "->"
},
{
"file": "/shopwaredir/vendor/symfony/http-kernel/HttpCache/HttpCache.php",
"line": 213,
"function": "invalidate",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/HttpKernel.php",
"line": 153,
"function": "handle",
"class": "Symfony\\Component\\HttpKernel\\HttpCache\\HttpCache",
"type": "->"
},
{
"file": "/shopwaredir/vendor/shopware/core/HttpKernel.php",
"line": 79,
"function": "doHandle",
"class": "Shopware\\Core\\HttpKernel",
"type": "->"
},
{
"file": "/shopwaredir/public/index.php",
"line": 74,
"function": "handle",
"class": "Shopware\\Core\\HttpKernel",
"type": "->"
}
],
"file": "/shopwaredir/vendor/doctrine/dbal/lib/Doctrine/DBAL/Driver/AbstractMySQLDriver.php",
"line": 125,
"previous": [Not included due to limited size of the issue description]
}
}
]}
I want the field shippingCosts to be auto generated. Is there anything I am doing wrong or is this a bug in Shopware 6?
While the shippingCosts object itself may not be required, some of its properties are. This endpoint was meant to persist pre-set data, not to calculate it on the fly.
So the short answer is that you're not doing anything wrong but it's not possible at the moment to achieve what you want. You'd have to calculate the shipping costs on your side.
Longer answer:
You'll have to write a plugin either way.
The first approach would require you to implement your own API controller that gets the RecalculationService injected and then call the service's recalculateOrder method after persisting your order_delivery.
The second approach: There's a recalculation endpoint of the admin api which I can't find documentation for at the moment (might not exist). Since live versions of orders are not allowed to be recalculated, you'll have to create a new version of the order first though: POST /api/_action/version/order/{orderId}. This will return a versionId for the order. You can use that in the header sw-version-id for the request to POST /api/_action/order/{orderId}/recalculate. In theory this would recalculate the delivery you persisted before and set the correct shipping costs.
However, the RecalculationService assembles a sales channel context using the OrderConverter at one point and there the permissions DeliveryProcessor::SKIP_DELIVERY_PRICE_RECALCULATION and DeliveryProcessor::SKIP_DELIVERY_TAX_RECALCULATION are hardcoded to true, meaning it actually won't recalculate those in the process. You'd probably have to decorate the OrderConverter Service with a plugin anyways and set these two to false.

IIOT OPCUA Alarms and Events node-red

I am working on OPC DA & AE. For that, I am using the IIOT OPCUA node in Node-red.
With the IIOT OPCUA node in Node-red I am able to connect and access data but for accessing the alarms and events not getting what to do.
I have tested my OPCAE server with the OPC expert tool and it's working fine but I want to execute alarms and events with Node-red.
Please help me out regarding this issue.
Thank you.
I haven´t worked with alarms and events yet but you or other people interessted may have a look on this discusion.
OPCUA-TEST-NODES.json contains an examples for testing events:
[
{
"id": "6413368d70ce7daa",
"type": "tab",
"label": "Test Nodes",
"disabled": false
},
{
"id": "42ce521b1148624d",
"type": "OpcUa-Event",
"z": "6413368d70ce7daa",
"root": "ns=0;i=2253",
"eventtype": "i=2041",
"name": "Events",
"x": 570,
"y": 480,
"wires": [
[
"59e10624d8d6798b",
"7bc93ab21da004f4"
]
]
},
{
"id": "50afc9882c32c9b1",
"type": "inject",
"z": "6413368d70ce7daa",
"name": "Test Events",
"props": [
{
"p": "payload"
},
{
"p": "topic",
"vt": "str"
}
],
"repeat": "",
"crontab": "",
"once": false,
"onceDelay": "",
"topic": "",
"payload": "",
"payloadType": "str",
"x": 370,
"y": 480,
"wires": [
[
"42ce521b1148624d"
]
]
},
{
"id": "59e10624d8d6798b",
"type": "OpcUa-Client",
"z": "6413368d70ce7daa",
"endpoint": "bb039652.dcf5a8",
"action": "events",
"deadbandvalue": "",
"time": 10,
"timeUnit": "s",
"localfile": "",
"localkeyfile": "",
"securitymode": "None",
"securitypolicy": "None",
"folderName4PKI": "",
"name": "A & C",
"x": 730,
"y": 480,
"wires": [
[
"47d20f3e7618f5db"
]
]
},
{
"id": "9598544e1e208e0c",
"type": "OpcUa-Client",
"z": "6413368d70ce7daa",
"endpoint": "bb039652.dcf5a8",
"action": "acknowledge",
"deadbandtype": "a",
"deadbandvalue": "5",
"time": "1",
"timeUnit": "s",
"localfile": "",
"localkeyfile": "",
"securitymode": "None",
"securitypolicy": "None",
"name": "ProSys NONE",
"x": 1060,
"y": 580,
"wires": [
[]
]
},
{
"id": "47d20f3e7618f5db",
"type": "debug",
"z": "6413368d70ce7daa",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 890,
"y": 480,
"wires": []
},
{
"id": "9a7458deff86b3b0",
"type": "inject",
"z": "6413368d70ce7daa",
"name": "Test Events",
"repeat": "",
"crontab": "",
"once": false,
"topic": "",
"payload": "",
"payloadType": "str",
"x": 370,
"y": 580,
"wires": [
[
"d02ed4a7087a2cd8"
]
]
},
{
"id": "d02ed4a7087a2cd8",
"type": "function",
"z": "6413368d70ce7daa",
"name": "AlarmID and EventID",
"func": "var msg;\nmsg.topic = \"ns=6;s=MyLevel.Alarm\";\nmsg.conditionId = \"ns=6;s=MyLevel.Alarm/0:EventId\";\nmsg.comment = \"Node-RED OPCUA Ack\";\nreturn msg;",
"outputs": 1,
"noerr": 0,
"x": 630,
"y": 580,
"wires": [
[
"9598544e1e208e0c"
]
]
},
{
"id": "7bc93ab21da004f4",
"type": "debug",
"z": "6413368d70ce7daa",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 730,
"y": 440,
"wires": []
},
{
"id": "bb039652.dcf5a8",
"type": "OpcUa-Endpoint",
"endpoint": "opc.tcp://H7Q8Q13.vstage.co:53530/OPCUA/SimulationServer",
"secpol": "None",
"secmode": "None",
"login": false
}
]
{
"id": "7bc93ab21da004f4",
"type": "debug",
"z": "6413368d70ce7daa",
"name": "",
"active": true,
"tosidebar": true,
"console": false,
"tostatus": false,
"complete": "true",
"targetType": "full",
"x": 730,
"y": 440,
"wires": []
},
{
"id": "bb039652.dcf5a8",
"type": "OpcUa-Endpoint",
"endpoint": "opc.tcp://H7Q8Q13.vstage.co:53530/OPCUA/SimulationServer",
"secpol": "None",
"secmode": "None",
"login": false
},
{
"id": "85144921.8931b8",
"type": "ui_group",
"name": "OPCUA",
"tab": "440c46c6.769ab8",
"order": 1,
"disp": true,
"width": "6",
"collapse": false
},
{
"id": "440c46c6.769ab8",
"type": "ui_tab",
"name": "Home",
"icon": "dashboard",
"disabled": false,
"hidden": false
}
]

Laravel Excel::Import using google cloud storage suddenly stopped working, gives error: mkdir(): No such file or directory

I've been using Laravel to import files uploaded to google cloud storage for a while.
Without changing any code, the following call suddenly stopped working.
Excel::import($importer, $document->path, env('GOOGLE_STORAGE_DISK', 'local'), $fileType);
The return error traced from the import method is below.
"message": "mkdir(): No such file or directory",
"exception": "ErrorException",
"file": "/workspace/vendor/maatwebsite/excel/src/Files/TemporaryFileFactory.php",
"line": 52,
"trace": [
{
"function": "handleError",
"class": "Illuminate\\Foundation\\Bootstrap\\HandleExceptions",
"type": "->"
},
{
"file": "/workspace/vendor/maatwebsite/excel/src/Files/TemporaryFileFactory.php",
"line": 52,
"function": "mkdir"
},
{
"file": "/workspace/vendor/maatwebsite/excel/src/Reader.php",
"line": 398,
"function": "makeLocal",
"class": "Maatwebsite\\Excel\\Files\\TemporaryFileFactory",
"type": "->"
},
{
"file": "/workspace/vendor/maatwebsite/excel/src/Reader.php",
"line": 99,
"function": "getReader",
"class": "Maatwebsite\\Excel\\Reader",
"type": "->"
},
{
"file": "/workspace/vendor/maatwebsite/excel/src/Excel.php",
"line": 146,
"function": "read",
"class": "Maatwebsite\\Excel\\Reader",
"type": "->"
},
{
"file": "/workspace/vendor/laravel/framework/src/Illuminate/Support/Facades/Facade.php",
"line": 261,
"function": "import",
"class": "Maatwebsite\\Excel\\Excel",
"type": "->"
},
{
"file": "/workspace/app/Http/Controllers/ImportController.php",
"line": 175,
"function": "__callStatic",
"class": "Illuminate\\Support\\Facades\\Facade",
"type": "::"
},
This is the line that throws the error in TemporaryFileFactory.php
if (!file_exists($this->temporaryPath) && !mkdir($concurrentDirectory = $this->temporaryPath) && !is_dir($concurrentDirectory)) {
I have no idea at all how to even begin to address this. Since I haven't made any code changes I can only assume a new version of some library is the culprit. However I have tried hard-coding the old library version in my composer.json
"maatwebsite/excel": "3.1.19",
and running composer install and it seems to make no difference. Any lead at all on what direction to go to try to solve this would be appreciated.
I decided to use '/tmp' instead,
to do so, I needed to publish and change the config/excel.php
php artisan vendor:publish –provider="Maatwebsite\Excel\ExcelServiceProvider"
edit config/excel.php
'local_path' => '/tmp',

Passing all files in a folder via Terraform

I'm building a monitoring stack for our internal projects. I would like for them to be able to design their own monitoring dashboards to be used inside Grafana so I cannot predict what those will be called.
I created a folder called grafana_dashboard, where I will be instructing them to store their dashboard as JSON files and I want to pass all the contents of that folder to the Grafana instance.
I have tried a number of variations of this :
resource "grafana_dashboard" "dashboards" {
for_each = fileset(path.module, "grafana_dashboard/*.json")
config_json = "${each.key}"
depends_on = [aiven_service.grafana]
}
But keep getting this error:
Error: invalid character 'g' looking for beginning of value
on ../modules/monitoring/grafana.tf line 139, in resource "grafana_dashboard" "dashboards":
139: resource "grafana_dashboard" "dashboards" {
Can any of you see what I'm doing wrong?
Here's an example of one of the .json files i'm trying to pass:
{
"annotations": {
"list": [
{
"builtIn": 1,
"datasource": "-- Grafana --",
"enable": true,
"hide": true,
"iconColor": "rgba(0, 211, 255, 1)",
"name": "Annotations & Alerts",
"type": "dashboard"
},
{
"datasource": "Prometheus",
"enable": true,
"expr": "sum(changes(nginx_ingress_controller_config_last_reload_successful_timestamp_seconds{instance!=\"unknown\",controller_class=~\"$controller_class\",namespace=~\"$namespace\"}[30s])) by (controller_class)",
"hide": false,
"iconColor": "rgba(255, 96, 96, 1)",
"limit": 100,
"name": "Config Reloads",
"showIn": 0,
"step": "30s",
"tagKeys": "controller_class",
"tags": [],
"titleFormat": "Config Reloaded",
"type": "tags"
}
]
},
"description": "Ingress-nginx supports a rich collection of prometheus metrics. If you have prometheus and grafana installed on your cluster then prometheus will already be scraping this data due to the scrape annotation on the deployment.",
"editable": false,
"gnetId": 9614,
"graphTooltip": 0,
"id": 18,
"iteration": 1574177838584,
"links": [],
"panels": [
{
"columns": [
{
"text": "Current",
"value": "current"
}
],
"datasource": "Prometheus",
"fontSize": "100%",
"gridPos": {
"h": 15,
"w": 24,
"x": 0,
"y": 0
},
"height": "1024",
"id": 85,
"links": [],
"options": {},
"pageSize": 15,
"scroll": true,
"showHeader": true,
"sort": {
"col": 1,
"desc": false
},
"styles": [
{
"alias": "Time",
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"pattern": "Time",
"type": "date"
},
{
"alias": "TTL",
"colorMode": "cell",
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"dateFormat": "YYYY-MM-DD HH:mm:ss",
"decimals": 0,
"pattern": "Current",
"thresholds": [
"0",
"691200"
],
"type": "number",
"unit": "s"
},
{
"alias": "",
"colorMode": null,
"colors": [
"rgba(245, 54, 54, 0.9)",
"rgba(237, 129, 40, 0.89)",
"rgba(50, 172, 45, 0.97)"
],
"decimals": 2,
"pattern": "/.*/",
"thresholds": [],
"type": "number",
"unit": "short"
}
],
"targets": [
{
"expr": "avg(nginx_ingress_controller_ssl_expire_time_seconds{kubernetes_pod_name=~\"$controller\",namespace=~\"$namespace\",ingress=~\"$ingress\"}) by (host) - time()",
"format": "time_series",
"instant": false,
"intervalFactor": 1,
"legendFormat": "{{ host }}",
"metric": "gke_letsencrypt_cert_expiration",
"refId": "A",
"step": 1
}
],
"title": "Ingress Certificate Expiry",
"transform": "timeseries_aggregations",
"type": "table"
}
],
"refresh": "5s",
"schemaVersion": 19,
"style": "dark",
"tags": [
"nginx"
],
"templating": {
"list": [
{
"allValue": ".*",
"current": {
"text": "All",
"value": "$__all"
},
"datasource": "Prometheus",
"definition": "",
"hide": 0,
"includeAll": true,
"label": "Namespace",
"multi": false,
"name": "namespace",
"options": [],
"query": "label_values(nginx_ingress_controller_config_hash, controller_namespace)",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"allValue": ".*",
"current": {
"text": "All",
"value": "$__all"
},
"datasource": "Prometheus",
"definition": "",
"hide": 0,
"includeAll": true,
"label": "Controller Class",
"multi": false,
"name": "controller_class",
"options": [],
"query": "label_values(nginx_ingress_controller_config_hash{namespace=~\"$namespace\"}, controller_class) ",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"allValue": ".*",
"current": {
"text": "All",
"value": "$__all"
},
"datasource": "Prometheus",
"definition": "",
"hide": 0,
"includeAll": true,
"label": "Controller",
"multi": false,
"name": "controller",
"options": [],
"query": "label_values(nginx_ingress_controller_config_hash{namespace=~\"$namespace\",controller_class=~\"$controller_class\"}, controller_pod) ",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 0,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
},
{
"allValue": ".*",
"current": {
"text": "All",
"value": "$__all"
},
"datasource": "Prometheus",
"definition": "",
"hide": 0,
"includeAll": true,
"label": "Ingress",
"multi": false,
"name": "ingress",
"options": [],
"query": "label_values(nginx_ingress_controller_requests{namespace=~\"$namespace\",controller_class=~\"$controller_class\",controller=~\"$controller\"}, ingress) ",
"refresh": 1,
"regex": "",
"skipUrlSync": false,
"sort": 2,
"tagValuesQuery": "",
"tags": [],
"tagsQuery": "",
"type": "query",
"useTags": false
}
]
},
"time": {
"from": "now-5m",
"to": "now"
},
"timepicker": {
"refresh_intervals": [
"5s",
"10s",
"30s",
"2m",
"5m",
"15m",
"30m",
"1h",
"2h",
"1d"
],
"time_options": [
"5m",
"15m",
"1h",
"6h",
"12h",
"24h",
"2d",
"7d",
"30d"
]
},
"timezone": "browser",
"title": "Cert-manager",
"uid": "nginx",
"version": 12
}
This works, so I know that I can do it, but doesn't suit my needs as I'd need to hardcode the name of each file:
resource "grafana_dashboard" "nginx_ingress_controller" {
config_json = templatefile("${path.module}/grafana_dashboard/nginx-ingress-controller.json", { DS_PROMETHEUS = local.prometheus_datasource_name })
depends_on = [aiven_service.grafana]
}
You need to actually use the file contents in your config_json parameter to the grafana_dashboard.
Switching your resource definition to the following should be enough:
resource "grafana_dashboard" "dashboards" {
for_each = fileset(path.module, "grafana_dashboard/*.json")
config_json = file("${path.module}/${each.key}")
depends_on = [aiven_service.grafana]
}

create contact from node.js to mautic uisng Mautic rest api

I am using mautic-node npm module for contacting mautic REST API from node.js.My aim is to create a contact from my app in mautic dashboard using mautic REST API,but i am facing issue in creating contact from node.js.Please help me to figure out this.
var mautic = require('mautic-api-node');
var request = require('request');
var config = require('../config/config.js');
var request = require('request');
exports.saveContact = (req, res) => {
queryParameters = JSON.stringify(req.body);
var username = "mauticUsername";
var password = "mauticPassword";
var auth = "Basic " + new Buffer.from(username + ":" +
password).toString("base64");
var options = {
url: 'https://mautic-url/api/contacts/new',
method: "POST",
form: queryParameters,
headers: {
"Authorization": auth
}
};
request(options, (error, response, body) => {
if (error) console.log(error);
console.log("Body", body);
})
}
I am passing this request body to backend:-
{
"firstname":"firstname",
"ipAddress":"Ipaddress",
"lastname":"lastname",
"email":"email"
}
when i run this code i am getting this response
Body {
"contact": {
"isPublished": true,
"dateAdded": "2019-06-08T10:06:25+00:00",
"dateModified": null,
"createdBy": 1,
"createdByUser": "username",
"modifiedBy": null,
"modifiedByUser": null,
"id": 1277,
"points": 0,
"color": null,
"fields": {
"core": {
"title": {
"id": 1,
"group": "core",
"label": "Title",
"alias": "title",
"type": "lookup",
"value": null
},
"firstname": {
"id": 2,
"group": "core",
"label": "First Name",
"alias": "firstname",
"type": "text",
"value": null
},
"lastname": {
"id": 3,
"group": "core",
"label": "Last Name",
"alias": "lastname",
"type": "text",
"value": null
},
"company": {
"id": 4,
"group": "core",
"label": "Primary company",
"alias": "company",
"type": "text",
"value": null
},
"position": {
"id": 5,
"group": "core",
"label": "Position",
"alias": "position",
"type": "text",
"value": null
},
"email": {
"id": 6,
"group": "core",
"label": "Email",
"alias": "email",
"type": "email",
"value": null
},
"mobile": {
"id": 7,
"group": "core",
"label": "Mobile",
"alias": "mobile",
"type": "tel",
"value": null
},
"phone": {
"id": 8,
"group": "core",
"label": "Phone",
"alias": "phone",
"type": "tel",
"value": null
},
"points": {
"id": 9,
"group": "core",
"label": "Points",
"alias": "points",
"type": "number",
"value": null
},
"fax": {
"id": 10,
"group": "core",
"label": "Fax",
"alias": "fax",
"type": "tel",
"value": null
},
"address1": {
"id": 11,
"group": "core",
"label": "Address Line 1",
"alias": "address1",
"type": "text",
"value": null
},
"address2": {
"id": 12,
"group": "core",
"label": "Address Line 2",
"alias": "address2",
"type": "text",
"value": null
},
"city": {
"id": 13,
"group": "core",
"label": "City",
"alias": "city",
"type": "text",
"value": null
},
"state": {
"id": 14,
"group": "core",
"label": "State",
"alias": "state",
"type": "region",
"value": null
},
"zipcode": {
"id": 15,
"group": "core",
"label": "Zip Code",
"alias": "zipcode",
"type": "text",
"value": null
},
"country": {
"id": 16,
"group": "core",
"label": "Country",
"alias": "country",
"type": "country",
"value": null
},
"preferred_locale": {
"id": 17,
"group": "core",
"label": "Preferred Locale",
"alias": "preferred_locale",
"type": "locale",
"value": null
},
"timezone": {
"id": 18,
"group": "core",
"label": "mautic.lead.field.timezone",
"alias": "timezone",
"type": "timezone",
"value": null
},
"last_active": {
"id": 19,
"group": "core",
"label": "Date Last Active",
"alias": "last_active",
"type": "datetime",
"value": null
},
"attribution_date": {
"id": 20,
"group": "core",
"label": "Attribution Date",
"alias": "attribution_date",
"type": "datetime",
"value": null
},
"attribution": {
"id": 21,
"group": "core",
"label": "Attribution",
"alias": "attribution",
"type": "number",
"value": null
},
"website": {
"id": 22,
"group": "core",
"label": "Website",
"alias": "website",
"type": "url",
"value": null
}
},
"social": {
"facebook": {
"id": 23,
"group": "social",
"label": "Facebook",
"alias": "facebook",
"type": "text",
"value": null
},
"foursquare": {
"id": 24,
"group": "social",
"label": "Foursquare",
"alias": "foursquare",
"type": "text",
"value": null
},
"googleplus": {
"id": 25,
"group": "social",
"label": "Google+",
"alias": "googleplus",
"type": "text",
"value": null
},
"instagram": {
"id": 26,
"group": "social",
"label": "Instagram",
"alias": "instagram",
"type": "text",
"value": null
},
"linkedin": {
"id": 27,
"group": "social",
"label": "LinkedIn",
"alias": "linkedin",
"type": "text",
"value": null
},
"skype": {
"id": 28,
"group": "social",
"label": "Skype",
"alias": "skype",
"type": "text",
"value": null
},
"twitter": {
"id": 29,
"group": "social",
"label": "Twitter",
"alias": "twitter",
"type": "text",
"value": null
}
},
"personal": [],
"professional": [],
"all": {
"id": 1277,
"title": null,
"firstname": null,
"lastname": null,
"company": null,
"position": null,
"email": null,
"mobile": null,
"phone": null,
"points": null,
"fax": null,
"address1": null,
"address2": null,
"city": null,
"state": null,
"zipcode": null,
"country": null,
"preferred_locale": null,
"timezone": null,
"last_active": null,
"attribution_date": null,
"attribution": null,
"website": null,
"facebook": null,
"foursquare": null,
"googleplus": null,
"instagram": null,
"linkedin": null,
"skype": null,
"twitter": null
}
},
"lastActive": null,
"owner": null,
"ipAddresses": [],
"tags": [],
"utmtags": null,
"stage": null,
"dateIdentified": null,
"preferredProfileImage": null,
"doNotContact": [],
"frequencyRules": []
}
}
This is the response of GET contacts API i guess so i am confused why i am getting GET API response while doing POST request to contact API please help me to figure out this issue.
As you can see in the picture, when you create a new contact along with response status code it returns the properties as well which are similar to "Get Contact" request(as you will get when you get contact by id). So I think as long as your new contact is being created in mautic you shouldn't be worried.

Resources