我正在使用此C#代码:
httpclient.DefaultRequestHeaders.Authorization = new AuthenticationHeaderValue("Bearer", accessToken);
var priceHistoryResponse = await _httpclient.GetAsync(priceHistoryUrlParameters);
if (priceHistoryResponse.StatusCode == HttpStatusCode.OK)
{
// Put the post response in a string named priceHistoryResponseContent
var priceHistoryResponseContent = await priceHistoryResponse.Content.ReadAsStringAsync().ConfigureAwait(false);
// Convert the priceHistoryContent string to JSON format
PriceHistory priceHistory = JsonConvert.DeserializeObject<PriceHistory>(priceHistoryResponseContent);
}
priceHistoryResponse为:
{StatusCode: 200, ReasonPhrase: 'OK', Version: 1.1, Content: System.Net.Http.HttpConnection+HttpConnectionResponseContent, Headers:{ Date: Sat, 01 Feb 2020 22:30:02 GMT Connection: keep-alive Host: api.tdameritrade.com X-Forwarded-For: 10.152.4.23 X-Forwarded-Port: 9002 X-Forwarded-Proto: http Authorization: Bearer roFzGtWR8xRppA7LlaZ280goscoXbGPwOfkxxxE NS-Proxy-Client-IP: 99.11.242.43 thirdparty: true Cache-Control: no-store, no-cache Access-Control-Allow-Origin: Access-Control-Allow-Headers: origin, x-requested-with, accept, authorization, content-type Access-Control-Max-Age: 3628800 Access-Control-Allow-Methods: GET, PUT, POST, DELETE, OPTIONS, HEAD Strict-Transport-Security: max-age=31536000 Content-Length: 0}}
这个priceHistoryUrlParameters网址看起来格式正确吗?
https://api.tdameritrade.com/v1/marketdata/AAPL/pricehistory/apikey=AMN%40AMER.OAUTHAP
我添加了/apikey=AMN%40AMER.OAUTHAP
答案 0 :(得分:0)
我将/更改为? 。按照建议。现在可以使用。