s***@gmail.com
2017-02-22 20:17:05 UTC
Hi,
New to vbscript and trying to troubleshoot an "Unspecified error"
I have been trying to glue this together from search results. It seems to try and run but getting the generic 80004005 error code which isn't helping. Small script hope someone can spot the problem.
Option Explicit
Dim objXmlHttpMain, user , password , URL, strJSONToSend
user = "testuser"
password = "testpass"
URL="https://testsitname.com/api/alert"
strJSONToSend = "{aligned_resource"": ""/device/17653"", ""message"": ""TESTING API""}"
Set objXmlHttpMain = CreateObject("Msxml2.ServerXMLHTTP")
On Error Resume Next
objXmlHttpMain.setRequestHeader "Content-Type", "application/json"
objXmlHttpMain.send strJSONToSend
objXmlHttpMain.open "POST",URL, False, user, password
If Err Then 'handle errors
WScript.Echo Err.Description & " [0x" & Hex(Err.Number) & "]"
WScript.Quit 1
End If
On Error Goto 0 'disable error handling again
New to vbscript and trying to troubleshoot an "Unspecified error"
I have been trying to glue this together from search results. It seems to try and run but getting the generic 80004005 error code which isn't helping. Small script hope someone can spot the problem.
Option Explicit
Dim objXmlHttpMain, user , password , URL, strJSONToSend
user = "testuser"
password = "testpass"
URL="https://testsitname.com/api/alert"
strJSONToSend = "{aligned_resource"": ""/device/17653"", ""message"": ""TESTING API""}"
Set objXmlHttpMain = CreateObject("Msxml2.ServerXMLHTTP")
On Error Resume Next
objXmlHttpMain.setRequestHeader "Content-Type", "application/json"
objXmlHttpMain.send strJSONToSend
objXmlHttpMain.open "POST",URL, False, user, password
If Err Then 'handle errors
WScript.Echo Err.Description & " [0x" & Hex(Err.Number) & "]"
WScript.Quit 1
End If
On Error Goto 0 'disable error handling again