一般来说,在 Exact Online 上,您可以使用 OData 批处理组合多个请求。这仅在流量流向一个端点 (URL) 时有效。
但是,您的问题本质上更具实用性。精确要求每笔交易至少有一行(我知道这很愚蠢,但要忍受它)。这适用于用户界面以及反映此业务规则的 API。
在您的 PurchaseOrder 创建事件中,您需要将这些行作为消息的一部分发送。
请查看https://start.exactonline.nl/docs/HlpRestAPIResourcesDetails.aspx?name=PurchaseOrderPurchaseOrders并在文中搜索“收藏”。
那里需要插入行(至少 1 行)。
当您不知道确切的语法时,请在 Invantive SQL 中使用 insert into exactonlinerest..purchaseorders ... identified by ... 然后运行它。在select * from sessionios@datadictionary 你会找到实际的电话。启用本机跟踪后,您可以在调试跟踪视图中看到发送到 Exact Online 的有效负载。
附带说明一下,对于上传数据,我通常更喜欢使用 XML API。它更快、更智能。
运行示例
启动 dbgview。
使用 INVANTIVE_TRACE_ACTIVE = true 环境变量启用跟踪日志记录。
启动invantive control或其他sql产品。
运行此代码以在新订单中创建每个销售订单的副本:
set trace-native-calls true
begin transaction
insert into exactonlinerest..salesorders
( description
, orderedby
, deliverto
, deliveryaddress
, invoiceto
)
select 'EDI order '
|| ' van '
|| to_char(sysdate, 'DD-MM-YYYY')
description
, sor.orderedby
label 'Ordered by account ID'
, sor.deliverto
label 'Deliver to account ID'
, sor.deliveryaddress
label 'Deliver to address ID'
, sor.invoiceto
label 'Invoice to account ID'
from ( select orderid, orderedby, invoiceto, deliverto, deliveryaddress from exactonlinerest..salesorders ) sor
identified
by sor.orderid
insert into exactonlinerest..salesorderlines
( description
, item
, quantity
, unitcode
)
select sle.description
, sle.item
, sle.quantity
, sle.unitcode
from exactonlinerest..salesorderlines sle
attach
to sle.orderid
commit
结果:
原生跟踪:
[49784] 15:02:21.82979-45: POST 962 bytes of data to URL '/api/v1/868047/salesorder/SalesOrders'. Disk cache: False/False, memory cache False/False.
[49784] 15:02:21.82979-45: Native request body on POST to 'https://start.exactonline.nl/api/v1/868047/salesorder/SalesOrders':
[49784] 15:02:21.82979-45: {"DeliverTo":"3ee8cdbc-e71c-4e8b-b4ee-922e84b05abf","DeliveryAddress":"fa6f3eb2-ba09-4c9f-aeb0-c967bdd8004f","Description":"EDI order van 08-12-2018","InvoiceTo":"3ee8cdbc-e71c-4e8b-b4ee-922e84b05abf","OrderedBy":"3ee8cdbc-e71c-4e8b-b4ee-922e84b05abf","SalesOrderLines":[{"Description":"Basebal handschoen links","Item":"ee4d1e32-4296-4460-908c-d109b9c2ac77","Quantity":25.0,"UnitCode":"stuk"},{"Description":"Basebal handschoen rechts","Item":"8ee41235-7688-4201-a142-ba56feb393c6","Quantity":10.0,"UnitCode":"stuk"},{"Description":"Basebal","Item":"1f61a71a-4503-407f-8b32-0f63f51a1dae","Quantity":50.0,"UnitCode":"stuk"},{"Description":"Energydrink","Item":"2d37742d-1101-49c6-8c09-59055a808415","Quantity":150.0,"UnitCode":"stuk"},{"Description":"Basebal knuppel","Item":"858cbee5-f597-4333-8679-4083c896cf9f","Quantity":30.0,"UnitCode":"stuk"},{"Description":"Energy reep","Item":"1cb1c87c-2dc4-4be9-8be6-54347403680d","Quantity":100.0,"UnitCode":"stuk"}]}
[49784] 15:02:21.89579-3: Response status 'OK', length 226.
还有更多消息。