Hello everyone I have this script in VBS:
On Error Resume Next
If WScript.Arguments.Count < 2 Then
WScript.Echo "This script requires arguments."
WScript.Quit
End If
Dim sURL, sAuth, sRequestType
sUrl = "http://192.168.10.6:8080/rest/servicedeskapi/request"
sAuth = "YWRtafW5pc3dRyYXRvcjdddpQdW50bs0dUMyE="
sRequestType = "POST"
Dim sArg1, sArg2, sArg3, sBody
sBody = "{""serviceDeskId"":2,""requestTypeId"":30,""requestFieldValues"":{""summary"":""sArg1"",""description"":""sArg2""}}"
sResponse = HTTPPost(sURL, sBody)
WScript.Echo sResponse
Function HTTPPost(sURL, sRequest)
Set oHTTP = CreateObject("MSXML2.ServerXMLHTTP")
oHTTP.open sRequestType, sURL, false
oHTTP.setRequestHeader "Content-Type", "application/json"
oHTTP.setRequestHeader "Content-Length", Len(sRequest)
oHTTP.setRequestHeader "Authorization", "Basic " & sAuth
oHTTP.send sRequest
HTTPPost = oHTTP.responseText
End Function
Everything seems to work fine expect the variables that i pass in the command line "sArg1, sArg2 and sArg3" get passed as exact text instead of variables, I have had this working on the past but I don't remember what I did to fix it.
csript.exe c:\folder\script.vbs testsarg1 testsarg2 testsarg3
Anything see anything wrong? I have tried playing around with "" around the args but that doesn't seem to help.
Many Thanks