c# - 响应中没有内容的 C# 状态 200
问题描述
我正在使用这个 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 url 的格式是否正确?
https://api.tdameritrade.com/v1/marketdata/AAPL/pricehistory/apikey=AMN%40AMER.OAUTHAP
我添加了 /apikey=AMN%40AMER.OAUTHAP
解决方案
我将 / 更改为 ? . 按照建议。现在可以了。
推荐阅读
- javascript - 如何在AngularJS中单击按钮时动态更改弹出标题范围变量
- reactjs - 如何在 React 中捕获 youtube iframe api 事件
- c - 如果换行符出现在空格之后,我在使用 scanf() 获取换行符时遇到问题
- reactjs - 添加到 react-native 视图的样式不能正常工作?
- c# - .net core 3 依赖注入服务作为“配置”的参数
- azure - 对象检测模型 - tensorflow 服务 - k8s 部署:需要很长时间 3-4 秒
- c - 多次输入变量 answer 会退出整个程序
- cassandra - TWCS 没有根据 window_size 和 window_unit 生成 SStables
- mysql - 如何将我的电子商务网站的流量部分转移到不同的 Google VPC?
- python - 程序在终端中加载时的三点动画