[英]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.