簡體   English   中英

使用 SharePoint URL 和 cURL 進行 URL 編碼

[英]URL encoding with SharePoint URL and cURL

我是使用CURL新手。 我正在嘗試連接到SharePoint URL 並以json的形式提取數據。 我的網址如下所示:

.../_api/web/lists/GetByTitle('titles list')/items

如果我提供沒有任何編碼的 URL,它會失敗並顯示HTTP/1.1 400 Bad Request錯誤。

我嘗試使用-G--data-urlencode如下所示:

curl -v -G -L --ntlm --user user:password -H 'Accept: application/json;odata=verbose' ".../_api/web/lists/GetByTitle" --data-urlencode "('titles list')" -d "/items"

這樣做會將我的 URL 轉換為.../_api/web/lists/GetByTitle?%28%27titles%20list%27%29&/items

但它因HTTP/1.1 404 Not Found而失敗,因為使用-G將附加到帶有? & ? &附加到 URL 會給我一個不同的 URL,因此404 not found錯誤。

我在訪問其他端點(如../_api/web/lists沒有問題,因為我猜不需要對其進行編碼。

如何正確編碼我的 URL 並在沒有任何錯誤的情況下獲取數據?

任何幫助,將不勝感激。 謝謝你。

我能夠通過將帶有編碼字符的 URL 直接提供給cURL命令來解決這個問題。 像這樣:

curl -v -L --ntlm --user user:password -H 'Accept: application/json;odata=verbose' ".../_api/web/lists/GetByTitle%28%27titles%20List%27%29/items"

我希望這可以幫助別人。 我知道我不是 linux 或cURL專家,歡迎對此提供更好的答案。

暫無
暫無

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

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