Warning: file_get_contents(/data/phpspider/zhask/data//catemap/4/maven/6.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
Vbscript 如何在vbs脚本中将API URI作为变量传递?_Vbscript - Fatal编程技术网

Vbscript 如何在vbs脚本中将API URI作为变量传递?

Vbscript 如何在vbs脚本中将API URI作为变量传递?,vbscript,Vbscript,我有Vb脚本运行Put请求。我有网址。该URL保存在excel中,我将该URL保存为变量,并将该URL传递给put命令 示例vURL: 我已经尝试过不同的论点和引语,但都不起作用 Dim args, vURL Set args = WScript.Arguments 'vURL = WScript.Arguments.Item(0) 'MSXML2.ServerXMLHTTP 'WinHttp.WinHttpRequest.5.1 'MSXML2.ServerXMLHTTP60 vURL =

我有Vb脚本运行Put请求。我有网址。该URL保存在excel中,我将该URL保存为变量,并将该URL传递给put命令

示例vURL:

我已经尝试过不同的论点和引语,但都不起作用

Dim args, vURL
Set args = WScript.Arguments

'vURL = WScript.Arguments.Item(0)
'MSXML2.ServerXMLHTTP
'WinHttp.WinHttpRequest.5.1
'MSXML2.ServerXMLHTTP60

vURL = args(0)
MsgBox vURL
Dim http: Set http = CreateObject("WinHttp.WinHttpRequest.5.1")
Dim url: url = vURL

With http
  Call .Open("PUT", url, False)
  Call .SetRequestHeader("Accept", "application/json")
  Call .SetRequestHeader("XAPI-KEY", "")
  Call .Send("")
End With

If Left(http.Status, 1) = 2 Then

  response = http.responseText
  MsgBox response
Else

  response = http.responseText
  MsgBox response
End If
如果我把vURL放在没有引号的地方。响应是空的,但它应该有某种响应

如果我将vURL放在引号中,响应返回为not Authority protocal


当我硬编码URL时,代码工作正常。

谢谢@omegastripes的帮助。通过比较硬编码URL和vURL的长度,我能够解决这个问题。长度不匹配。

请共享用于启动VBScript的rest VBA代码的相关部分。为什么需要在单独的VBS中以这种方式运行PUT请求?为什么不在VBA中运行它呢?我们正在使用Automation Anywhere传递vURL变量。这是vbs脚本,因为automation anywhere只能运行vbs脚本。我应该澄清这一点。我们没有使用VBA。我更新了问题,说vbs脚本
MsgBox vURL
这会产生预期的结果吗?比较工作正常的硬编码URL和参数中的URL。可能会添加一些空白字符。在
MsgBox vURL
之后添加以下行:
vHardCoded=”https://example.com/api/“
MsgBox vHardCoded=vURL
MsgBox Trim(vHardCoded)=Trim(vURL)
MsgBox Len(vHardCoded)
MsgBox Len(vURL)
。您能否将此解决方案作为问题的答案发布,以帮助他人?