0

我正在尝试使用 odata 从邮递员发布采购订单行详细信息,但出现以下错误。

{
"error": {
    "code": "",
    "message": "An error has occurred.",
    "innererror": {
        "message": "Write validation failed for table row of type 'PurchPurchaseOrderLineEntity'. Infolog: .",
        "type": "Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataValidateWriteException",
        "stacktrace": "   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateProcessor.CreateEntity_Save(ChangeOperationContext context, ChangeInfo changeInfo)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.<>c__DisplayClass10_0.<CreateEntity>b__1(ChangeOperationContext context)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.ExecuteActionsInCompanyContext(IEnumerable`1 actionList, ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.ChangeInfo.TrySave(ChangeOperationContext operationContext)\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.Update.UpdateManager.SaveChanges()\r\n   at Microsoft.Dynamics.Platform.Integration.Services.OData.AxODataDelegatingHandler.<SaveChangesAsync>d__3.MoveNext()"
    }
}

}

我试过检查这些链接,但我没有取得突破:

下面是我的有效载荷

{      
            "dataAreaId": "XXXX",
            "LineNumber": 1,
            "PurchaseOrderNumber": "XXXX-PO-000009",
            "ReceivingSiteId": "1",
            "LineDescription": "XXXXXXX XXXX XXXX",
            "ItemNumber": "SKU0000012530",
            "DIOTOperationType": "Blank",
            "LineAmount": 9687.19,
            "PurchasePriceQuantity": 1,
            "PurchasePrice": 9687.19,
            "PurchaseUnitSymbol": "EA",
            "OrderedPurchaseQuantity": 1,
            "DeliveryAddressName": "XXXXX XXXXX XXXX",
            "ProcurementProductCategoryName": "XXXXXX XXXXX XXXX",
            "ReceivingWarehouseId": "TG",
            "VendorInvoiceMatchingPolicy": "ThreeWayMatch",
            "RequestedDeliveryDate": "2021-09-03T12:00:00Z"
}

任何人都可以帮助我吗?

注意:采购订单标题正常工作。

4

1 回答 1

4

尽管问题中缺少信息,但我试图重现该问题。我的测试设置是带有 contoso 演示数据的 10.0.20 环境。我使用了 DEMF 公司并创建了一个新的采购订单,因为现有的采购订单已经开票和/或内部公司。

我为供应商 DE-001 创建了新的采购订单,并且能够使用 Postman 发送的 OData 请求在其中创建行。

在测试时,我注意到 Postman 收到的响应确实包含问题中缺少的信息日志消息。它们已被删除(在这种情况下,请[编辑] 问题并添加它们)或 D365 的版本不包含它们(在这种情况下,请[编辑] 问题以添加版本信息)。

我还注意到问题中的有效负载包含字段ItemNumberProcurementProductCategoryName. 据我所知,一条采购线只能有这两者之一,但不能两者兼有。如果您手动创建一条线,另一条线将被锁定以进行编辑。因此,请在没有ItemNumberProcurementProductCategoryName字段的情况下重试您的请求。

作为记录,以下是在我的测试设置中工作的有效负载:

采购类别的有效载荷

{      
            "dataAreaId": "DEMF",
            "LineNumber": 1,
            "PurchaseOrderNumber": "000011",
            "ReceivingSiteId": "1",
            "LineDescription": "XXXXXXX XXXX XXXX",
            "ProcurementProductCategoryName": "PAYROLL",
            "DIOTOperationType": "Blank",
            "LineAmount": 47.11,
            "PurchasePriceQuantity": 1,
            "PurchasePrice": 47.11,
            "PurchaseUnitSymbol": "EA",
            "OrderedPurchaseQuantity": 1,
            "DeliveryAddressName": "XXXXX XXXXX XXXX",
            "ReceivingWarehouseId": "11",
            "VendorInvoiceMatchingPolicy": "ThreeWayMatch",
            "RequestedDeliveryDate": "2021-09-03T12:00:00Z"
}

带有项目编号的有效载荷

{      
            "dataAreaId": "DEMF",
            "LineNumber": 1,
            "PurchaseOrderNumber": "000009",
            "ReceivingSiteId": "1",
            "LineDescription": "XXXXXXX XXXX XXXX",
            "ItemNumber": "D0001",
            "DIOTOperationType": "Blank",
            "LineAmount": 47.11,
            "PurchasePriceQuantity": 1,
            "PurchasePrice": 47.11,
            "PurchaseUnitSymbol": "EA",
            "OrderedPurchaseQuantity": 1,
            "DeliveryAddressName": "XXXXX XXXXX XXXX",
            "ReceivingWarehouseId": "11",
            "VendorInvoiceMatchingPolicy": "ThreeWayMatch",
            "RequestedDeliveryDate": "2021-09-03T12:00:00Z"
}

于 2021-08-16T15:21:35.840 回答