json - 无法在本地连接到远程服务器
问题描述
string url = ConfigurationManager.AppSettings["CorreURL"].ToString(); https://ourwebsite.com/Transmit
string json = JsonConvert.SerializeObject(claim, Formatting.Indented);
WebRequest request = WebRequest.Create(url);
request.ContentType = "application/json";
request.Method = "GET";
request.Headers.Add("Authorization", "passwordgoesherebuthiddenfromstackoverflow");
Type type = request.GetType();
Object currentMethod = type.GetProperty("CurrentMethod", BindingFlags.NonPublic | BindingFlags.Instance).GetValue(request);
Type methodType = currentMethod.GetType();
methodType.GetField("ContentBodyNotAllowed", BindingFlags.NonPublic | BindingFlags.Instance).SetValue(currentMethod, false);
//i get the error here:
using (StreamWriter streamWriter = new StreamWriter(request.GetRequestStream()))
{
streamWriter.Write(json);
}
我想要做的是向我们的服务器发送一个 json 文件(该文件没问题,因为我在 lint 上对其进行了测试)以处理该文件。我们使用邮递员,我从那里得到了信誉,但没有运气。我希望这是足够的信息。如果我需要提供更多信息,请告诉我。上面的代码是刚刚pw隐藏的所有代码。
提前致谢
解决方案
推荐阅读
- c++ - 在一个字符串中多次查找相同的字符串
- php - PHP 无法播放 .m3u8 直播
- javascript - 尝试打开未安装的应用程序时如何防止 iOS Safari 错误警报?
- sql - 在 SQL 中选择 Unicode 的范围
- python - 在 Python 3.5 中用大括号包围的单词解析字符串到数组
- c# - 使用 C# 使用 ESC/POS 命令在 EPSON LX-300+II 上打印图像
- android - 自定义对话框中的按钮问题(在 RecyclerView 适配器中创建)
- php - 如何在 Laravel 中更改格式化日期时间的语言
- vba - 如果在 VBA 中满足条件,则减少负载
- javascript - 删除文件之前的 Dropzone 事件