我正在尝试研究如何使用 PowerShell 作为客户端进行 OData 更新。我找到了用于测试的站点services.odata.org:http://services.odata.org/OData/OData.svc/$metadata。
我试过这个:
Invoke-RestMethod -Method Put -ContentType 'application/json' `
-Uri 'http://services.odata.org/V3/(S(k22mmq0ajlv45epd2psyysnd))/OData/OData.svc/Products(0)' `
-Body ( @{ Description = 'CheesyPeas' } | ConvertTo-Json )
但我回来了
Invoke-RestMethod : <?xml version="1.0" encoding="utf-8"?>
<m:error xmlns:m="http://schemas.microsoft.com/ado/2007/08/dataservices/metadata">
<m:code />
<m:message xml:lang="en-US">
Error processing request stream. Type information must be specified for types that take part in inheritance.
</m:message>
</m:error>
At line:1 char:1
+ Invoke-RestMethod -Uri 'http://services.odata.org/V3/(S(k22mmq0ajlv45epd2psyysnd ...
+ ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~
+ CategoryInfo : InvalidOperation: (System.Net.HttpWebRequest:HttpWebRequest) [Invoke-RestMethod], WebException
+ FullyQualifiedErrorId : WebCmdletWebResponseException,Microsoft.PowerShell.Commands.InvokeRestMethodCommand
我认为这与导航属性有关。理想情况下,我将针对没有导航属性的简单实体进行测试,直到我有一个基本的 PUT 工作但我找不到一个。谁能帮我搞定这个工作?