【问题标题】:There is no response when i publish the restsharp cod program on windows我在windows上发布restsharp cod程序时没有响应
【发布时间】:2018-05-17 11:38:38
【问题描述】:

我有一个使用 RestSharp 和 Newtonsoft.Json 包登录的代码。这段代码是这样的:

Dim client = New RestClient("https://api.mysite.com/auth/login")
Dim request = New RestRequest(Method.POST)
request.AddHeader("authentication-key", "123")
request.AddHeader("authentication-id", "123")
request.AddParameter("application/x-www-form-urlencoded", "username=123&password=123", ParameterType.RequestBody)
Dim response As RestResponse = client.Execute(request)

 MsgBox(response.Content.ToString)
    If response.StatusCode.ToString = "OK" Then
        'Save token
        Dim result = JsonConvert.DeserializeObject(response.Content.ToString)
    End If

当我在 Visual Studio 中运行此代码时,它可以工作。但是当我为 windows 发布它时,MsgBox 中没有响应。当我在我的计算机(安装的 Visual Studio)中运行已发布的程序时,它可以工作并显示服务器的响应,但是当我在其他计算机上运行已发布的代码时,响应为空。请帮我 。

【问题讨论】:

    标签: json vb.net json.net publish restsharp


    【解决方案1】:

    两天后我终于可以解决这个问题了。这个错误有两个原因。

    1- 在源代码中将application/x-www-form-urlencoded 更改为application/json

    2- 在用户计算机上使用 .NetFamework 4.7.2 版。

    【讨论】:

      猜你喜欢
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 1970-01-01
      • 2013-02-21
      • 2016-05-08
      • 1970-01-01
      相关资源
      最近更新 更多