使用 WarehouseDetails 更新 StockItem

Updating StockItem with WarehouseDetails

是否有人成功更新了包含 WarehouseDetails 数组的库存商品?在我尝试过的每一个变体中,我都不断地得到一个堆栈转储。我们正在使用 Manufacturing 模块,我不确定这是否会对行为产生影响。

PUT http:///myserver-name-here/entity/Default/20.200.001/StockItem/$expand=WarehouseDetails

{
    "id": "0aeba316-893b-eb11-817c-06ec5f1e3982",
    "InventoryID": {"value": "MYSKU.VALUE"},            
    "WarehouseDetails": [
        {
            "id": "0ceba316-893b-eb11-817c-06ec5f1e3982",
            "rowNumber": {"value": 1},
            "DefaultIssueLocationID": {"value": "WH1"},
            "DefaultReceiptLocationID": {"value": "WH2"} ,
            "WarehouseID": {"value": "LOCATION1"},
            "custom": {},
            "files": [],
            "note": {"value": ""}
        },
        {
            "id": "d070a3df-d343-eb11-817c-06ec5f1e3982",   
            "rowNumber": {"value": 2},
            "DefaultIssueLocationID": {"value": "WH3"},
            "DefaultReceiptLocationID": {"value": "WH4"}    ,
            "WarehouseID": {"value": "LOCATION2"}    ,
            "custom": {},
            "files": [],
            "note": {"value": ""}    
        }
    ]
}

堆栈转储总是这样

{
    "message": "An error has occurred.",
    "exceptionMessage": "Specified argument was out of the range of valid values.\r\nParameter name: Invalid uri structure",
    "exceptionType": "System.ArgumentOutOfRangeException",
    "stackTrace": "   at System.Monads.ArgumentCheck.Check[TSource](TSource source, Func`2 checkCondition, Func`2 exceptionSource)\r\n   at PX.Api.ContractBased.SystemContracts.V2.RestController.PutFile(String objectName, String ids)\r\n   at lambda_method(Closure , Object , Object[] )\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ActionExecutor.<>c__DisplayClass6_2.<GetExecutor>b__2(Object instance, Object[] methodParameters)\r\n   at System.Web.Http.Controllers.ReflectedHttpActionDescriptor.ExecuteAsync(HttpControllerContext controllerContext, IDictionary`2 arguments, CancellationToken cancellationToken)\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ApiControllerActionInvoker.<InvokeActionAsyncCore>d__1.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<CallOnActionExecutedAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.ActionFilterAttribute.<ExecuteActionFilterAsyncCore>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ActionFilterResult.<ExecuteAsync>d__5.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Filters.AuthorizationFilterAttribute.<ExecuteAuthorizationFilterAsyncCore>d__3.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Web.Http.Controllers.ExceptionFilterResult.<ExecuteAsync>d__6.MoveNext()\r\n--- End of stack trace from previous location where exception was thrown ---\r\n   at System.Runtime.ExceptionServices.ExceptionDispatchInfo.Throw()\r\n   at System.Runtime.CompilerServices.TaskAwaiter.HandleNonSuccessAndDebuggerNotification(Task task)\r\n   at System.Web.Http.Dispatcher.HttpControllerDispatcher.<SendAsync>d__15.MoveNext()"
}

不要在 StockItem 后面加反斜杠,记住它是输入任何参数的问号。这就是您收到无效 uri 错误的原因。

https://{{baseUrl}}/entity/Default/20.200.001/StockItem?$expand=WarehouseDetails