2017-07-26 66 views
0

我需要從服務器獲取一些數據,並將URL作爲Base64提供給我。我通常使用法拉第連接到JSON API(這是返回格式)。這是一個基本的例子,包括錯誤,我得到:在Ruby on Rails中請求使用Faraday的Base64編碼的URL

url = "data:application/json;base64,srighiuerghieurg..." 
Faraday.get(url) 

#=> URI::InvalidURIError: query conflicts with opaque 

打開網址在任何瀏覽器產生預期的JSON,但我怎樣才能使利用法拉第這項工作?

爲了讓您的請求的結構的一個想法:

curl 'https://some.site.net/1/indexes/*/queries?some-agent=...' -H 'Accept: application/json' -H 'Accept-Encoding: gzip, deflate, br' -H 'Accept-Language: en-US,en;q=0.5' -H 'Connection: keep-alive' -H 'Content-Type: application/x-www-form-urlencoded' -H 'DNT: 1' -H 'Host: some.site.net' -H 'Origin: https://another.site.com -H 'Referer: https://another.site.com/some/path' -H 'User-Agent: Mozilla/5.0 (Windows NT 10.0; Win64; x64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/42.0.2311.135 Safari/537.36 Edge/12.10240' --data '{"requests":[{"index":"some-name","params":"some=params"}]}' 
+0

你能檢查協議是否存在於url(http/https) – Sajin

+0

@Sajin它不是。以上是我得到的一切。 – Severin

+0

您是否嘗試過從Base64解碼網址,並將該值用作網址? – Nermin

回答