以文本方式查看主题

-  Foxtable(狐表)  (http://www.foxtable.com/bbs/index.asp)
--  专家坐堂  (http://www.foxtable.com/bbs/list.asp?boardid=2)
----  [求助]post json 提示出错  (http://www.foxtable.com/bbs/dispbbs.asp?boardid=2&id=158849)

--  作者:mxko
--  发布时间:2020/12/4 11:40:00
--  [求助]post json 提示出错
You must write ContentLength bytes to the request stream before calling [Begin]GetResponse.
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2020.1.19.19
错误所在事件:
详细错误信息:
You must write ContentLength bytes to the request stream before calling [Begin]GetResponse.

代码如下:
Dim AppId As String= "XXXXX" 
Dim AppSecret As String = "XXXXX" 
Dim url As String = "XXXXXXXXXXX"
Dim so As New JObject
so("username") = AppId
so("password") = AppSecret
Output.Show(CompressJson(so))
Dim hc As New HttpClient(url)
hc.Content=CompressJson(so)
Dim ret As String = hc.GetData()
Output.Show(ret)
[此贴子已经被作者于2020/12/4 11:40:34编辑过]

--  作者:有点蓝
--  发布时间:2020/12/4 11:44:00
--  
接口开发文档发上来看看
--  作者:mxko
--  发布时间:2020/12/4 12:39:00
--  
请求体
Header:
Content-Type: application/json
Body:
{
"username": "XXXXXXXXXX",
"password": "XXXXXXXXXX"
}
 
 用Postman要用raw-JSON

图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20201204124325.png
图片点击可在新窗口打开查看

[此贴子已经被作者于2020/12/4 12:42:52编辑过]

--  作者:有点蓝
--  发布时间:2020/12/4 13:35:00
--  
Dim hc As New HttpClient(url)
hc.ContentType = "application/json"
hc.Content=CompressJson(so)
[此贴子已经被作者于2020/12/4 13:35:09编辑过]

--  作者:mxko
--  发布时间:2020/12/4 14:34:00
--  
以下是引用有点蓝在2020/12/4 13:35:00的发言:
Dim hc As New HttpClient(url)
hc.ContentType = "application/json"
hc.Content=CompressJson(so)
[此贴子已经被作者于2020/12/4 13:35:09编辑过]

还不行,怎么加 ContentLength
[此贴子已经被作者于2020/12/4 14:34:35编辑过]

--  作者:有点蓝
--  发布时间:2020/12/4 14:41:00
--  
应该和ContentLength没有关系,完整开发文档发上来看看
--  作者:mxko
--  发布时间:2020/12/4 14:48:00
--  
以下是引用mxko在2020/12/4 12:39:00的发言:
请求体
Header:
Content-Type: application/json
Body:
{
"username": "XXXXXXXXXX",
"password": "XXXXXXXXXX"
}
 
 用Postman要用raw-JSON

图片点击可在新窗口打开查看此主题相关图片如下:微信图片_20201204124325.png
图片点击可在新窗口打开查看

[此贴子已经被作者于2020/12/4 12:42:52编辑过]

这个就是了,用postman可以获取
--  作者:有点蓝
--  发布时间:2020/12/4 15:08:00
--  
这样看不出到底什么问题
--  作者:mxko
--  发布时间:2020/12/4 15:19:00
--  
You must write ContentLength bytes to the request stream before calling [Begin]GetResponse.
.NET Framework 版本:4.0.30319.42000
Foxtable 版本:2020.1.19.19
错误所在事件:
详细错误信息:
You must write ContentLength bytes to the request stream before calling [Begin]GetResponse.
看报错信息也不知道吗?

--  作者:有点蓝
--  发布时间:2020/12/4 16:34:00
--  
客服那边说加一句

Net.ServicePointManager.SecurityProtocol = Net.SecurityProtocolType.Tls11
Dim hc As New HttpClient(url)
hc.ContentType = "application/json"
hc.Content=CompressJson(so)