我正在将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
之类的错误。参数已经是一个字符串。
有什么主意吗?