当我试图像这样从雅虎获取历史数据时:
private fun getStockHistoricalData(){
val queue = VolleySingleton.getInstance(this)
val query = "https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1635962336&period2=1667498336&interval=1d&events=history&includeAdjustedClose=true"
val request = StringRequest( Request.Method.GET,query,
{ response ->
println("response = $response")
},
{ error ->
println("Error ${parseVolleyError(error)}")
}
)
request.setShouldCache(false)
queue.addToRequestQueue(request)
}
我收到以下错误:Value Forbidden of type java.lang.String cannot be converted to JSONObject
和以下内容:
NetworkUtility.shouldRetryException: Unexpected response code 403 for https://query1.finance.yahoo.com/v7/finance/download/AAPL?period1=1635962336&period2=1667498336&interval=1d&events=history&includeAdjustedClose=true
查询运行良好.你可以试一下postman 或浏览器.我还try 了不同的变种,比如JsonObjectRequest
或Method.POST
,而不是GET
.改装也没有奏效.它以前甚至还起作用了.