VB6 XmlHttp.send STRING无法正常工作。使用Cstr(String)修复。帮助了解

时间:2019-05-22 21:21:32

标签: vb6 xmlhttprequest

我正在将Visual Basic 6用于旧的视频游戏,并且正在实现用Node.js编写的API。 (http://www.argentumonline.org

反正这是我的职责

Public Sub ApiEndpointSendResetPasswordAccountEmail(ByVal Email As String, ByVal NewPassword As String)
    'Este endpoint envia un email para cambiar password al usuario

    UrlServer = GetVar(IniPath & "Server.ini", "CONEXIONAPI", "UrlServer") & "/api/v1/emails/resetAccountPassword"

    Dim Parameters As String
    Parameters = "newPassword=" & NewPassword & "&emailTo=" & Email

    Call SendPOSTRequest(UrlServer, Parameters)
End Sub


Private Sub SendPOSTRequest(ByVal Endpoint As String, ByVal Parameters As String)
On Error GoTo ErrorHandler

    Set XmlHttp = CreateObject("Microsoft.XmlHttp")

    XmlHttp.Open "POST", Endpoint, False
    XmlHttp.setRequestHeader "Content-Type", "application/x-www-form-urlencoded"

    'Por alguna razon tengo que castearlo a string, sino no funciona, la verdad no tengo idea por que ya que la variable es String
    XmlHttp.send CStr(Parameters)

ErrorHandler:
    If Err.Number <> 0 Then
        Call LogError("Error POST endpoint: " & Endpoint & ". La Api parece estar offline. " & Err.Number & " - " & Err.description)
    End If
End Sub

代码工作正常,但在此行中: XmlHttp.send CStr(Parameters)如果我不将Parameters强制转换为字符串,则该应用程序将无法运行,并且XmlHttp会显示类似The Resource can not be found之类的错误。参数已经是一个字符串。

有什么主意吗?

0 个答案:

没有答案