How to POST JSON Data via HTTP API using VBScript? How to POST JSON Data via HTTP API using VBScript? json json

How to POST JSON Data via HTTP API using VBScript?


Going out on a limb here, since you didn't deem it necessary to include the actual error message. You're most likely getting an "invalid character" error in line 3. That's because you need to define your JSON string as an actual string.

Change this:

strJSONToSend = {"type": "note", "title": "Alert", "body": "Lorem Ipsum Lorem Ipsum Lorem Ipsum."}

into this:

strJSONToSend = "{""type"": ""note"", ""title"": ""Alert"", ""body"": ""Lorem Ipsum Lorem Ipsum Lorem Ipsum.""}"

Edit: As a side-note, if you're using On Error Resume Next in your code always put proper error handling in place, and also keep it as localized as possible:

On Error Resume Next   'enable error handlingobjXmlHttpMain.open "POST",URL, FalseIf Err Then            'handle errors  WScript.Echo Err.Description & " [0x" & Hex(Err.Number) & "]"  WScript.Quit 1End IfOn Error Goto 0        'disable error handling again