我正在尝试使用Microsoft Dynamics导航中的Simple.OData.Client通过OData Web服务发布SalesOrder的新条目。
此有效:
ODataClientSettings settings = new ODataClientSettings();
settings.BaseUri = new Uri(Constants.ODataServiceEndpoint);
settings.Credentials = new NetworkCredential(Constants.SecureUserName, Constants.SecureUserPassword);
client = new ODataClient(settings);
var items = await client
.For("SalesOrder")
.FindEntriesAsync();
不幸的是,这不起作用,我不知道为什么:
var product = await client
.For<SalesOrder>("SalesOrder")
.Set(CreateDummyOrder())
.InsertEntryAsync();
我收到此异常:
Exception caught : Simple.OData.Client.WebRequestException: Internal Server Error
at Simple.OData.Client.RequestRunner.PostExecute(HttpResponseMessage responseMessage)
at Simple.OData.Client.RequestRunner.ExecuteRequestAsync(ODataRequest request, CancellationToken cancellationToken)
at Simple.OData.Client.ODataClient.ExecuteRequestWithResultAsync[T](ODataRequest request, CancellationToken cancellationToken, Func`2 createResult, Func`1 createEmptyResult, Func`1 createBatchResult)
at Simple.OData.Client.ODataClient.InsertEntryAsync(FluentCommand command, Boolean resultRequired, CancellationToken cancellationToken)
at Simple.OData.Client.BoundClient`1.InsertEntryAsync(Boolean resultRequired, CancellationToken cancellationToken)
答案 0 :(得分:0)
最后,我找出了问题所在。
对于要处理它的每个人,都必须使用 OData V4 URL 。尽管我不确定为什么该发布不适用于OData V3 URL。之后,您必须启用手册编号。