簡體   English   中英

Sharepoint Online - Rest API 過濾器不起作用

[英]Sharepoint Online - Rest API Filter doesn't work

我正在嘗試使用過濾器參數發出 REST API 請求。 我的網址在瀏覽器中工作正常,但在 JS 請求中沒有。

https://xxxx.sharepoint.com/sites/myTestPage/_api/web/lists/getbytitle ('ListDemo')/Items?$top=200&$select=State

任何參數條件都有效,請任何人幫助我。

下面是我用來測試和制作 JS 文件的相同步驟的 powershell 腳本:

$url = "https://xxxx.sharepoint.com/sites/myTestPage/_api/web/lists/getbytitle('ListDemo')/Items?$top=200&$select=State"
$headers = @{}      
$headers.Add("Authorization","Bearer " + $bearerCode)                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                                          
$headers.Add("accept","application/json; odata=minimalmetadata")
#$headers.Add("content-type","application/json;odata=verbose")
$headers.Add("content-type","application/json;odata=minimalmetadata")
$headers.Add("Control-Allow-Origin","https://xxxx.sharepoint.com")
$headers.Add("Origin","https://xxxx.sharepoint.com")

$response = Invoke-WebRequest -Uri $url -Method GET -Header $headers
Write-host $response.RawContent

在我的 JS 請求中,url 位於: $filter=City eq 'DC' ,但字符'必須編碼為%27並且在比較命令之前和之后需要對空格( %20 )字符采用相同的方法,就我而言, eg

因此,要解決此問題,正確的 url 必須具有以下過濾器:

$filter=City%20eg%20%27DC%27

暫無
暫無

聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM