0
我想解決如何使用PowerShell作爲客戶端來做OData更新。我發現網站services.odata.org用於測試:http://services.odata.org/OData/OData.svc/ $元數據。如何使用PowerShell通過OData服務更新實體?
我已經試過這樣:
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工作,但我找不到一個。任何人都可以幫助我做到這一點?
衛生署!非常感謝你。 – user2871239