[英]Azure Data Factory - Copy Activity - rest api collection reference
Helo eveyone,大家好,
I am fairly new to Data Factory and I need to copy information from Dynamics Business Central's Rest API.我是数据工厂的新手,我需要从 Dynamics Business Central 的 Rest API 复制信息。 I am struggling with the "Details" type entities such as "invoiceSalesHeader".我正在努力处理“详细信息”类型的实体,例如“invoiceSalesHeader”。
The api for that entity forces me to provide a header ID as a filter.该实体的 api 强制我提供标题 ID 作为过滤器。 In that sense, I would have to loop x times (a few thousand) and call the Rest API to retreive the lines of each sales invoice.从这个意义上说,我必须循环 x 次(几千次)并调用 Rest API 来检索每张销售发票的行。 I find that completely ridiculous and am trying to find other ways to get the information.我觉得这完全是荒谬的,我正在努力寻找其他方式来获取信息。
To avoid doing that, I am trying to get the information by calling the "salesInvoice" entity and use "$expand=salesInvoiceLines".为了避免这样做,我试图通过调用“salesInvoice”实体并使用“$expand=salesInvoiceLines”来获取信息。
That gets me the information I need but inside data factory's Copy Activity, I am struggling with what I should put as a "collection reference" so that I end up with one row per salesInvoiceLine.这为我提供了我需要的信息,但在数据工厂的复制活动中,我正在努力解决我应该将其作为“集合参考”的内容,以便每个 salesInvoiceLine 最终得到一行。
The data returned is an array of sales invoices with a sub array of invoice lines.返回的数据是带有发票行子数组的销售发票数组。
If I select "salesInvoiceLines" as the collection reference, I end up with "$['value'][0]['salesInvoiceLines']" and that only gives me the lines for the first invoice (since there is an index of zero).如果我选择“salesInvoiceLines”作为集合参考,我最终会得到“$['value'][0]['salesInvoiceLines']”并且只给我第一张发票的行(因为索引为零)。
What should I put in Collection Reference so that I get one row per salesInvoiceLine我应该在 Collection Reference 中放入什么,以便每个 salesInvoiceLine 获得一行
It is not support to foreach nested json array in ADF.不支持在 ADF 中 foreach 嵌套的 json 数组。
Alternatively, we can use a Flattern activity in data flow to flatten the nested json array.或者,我们可以在数据流中使用 Flattern 活动来展平嵌套的 json 数组。
Here is my example:这是我的例子:
This is my example json data, the structure is like yours:这是我的示例 json 数据,结构与您的类似:
[
{
"id": 1,
"Value": "January",
"orders":[{"orderid":1,"orderno":"qaz"},{"orderid":2,"orderno":"edc"}]
},
{
"id": 2,
"Value": "February",
"orders":[{"orderid":3,"orderno":"wsx"},{"orderid":4,"orderno":"rfv"}]
},
{
"id": 3,
"Value": "March",
"orders":[{"orderid":5,"orderno":"rfv"},{"orderid":6,"orderno":"tgb"}]
},
{
"id": 11,
"Value": "November",
"orders":[{"orderid":7,"orderno":"yhn"},{"orderid":8,"orderno":"ujm"}]
}
]
In the dataflow, we can select the header of the nested json array, here is orders
:在数据流中,我们可以选择嵌套 json 数组的头部,这里是orders
:
Then we can see the result, we have transposed the JSON orders
array with 2 objects (orderid, orderno) into 8 flatten rows:然后我们可以看到结果,我们已经将包含 2 个对象(orderid、orderno)的 JSON orders
数组转置为 8 个扁平行:
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.